Monday, March 16, 2015

Helpful Standard Programs



1) RSTXPDFT4 - To download PDF from Spool.

2) RSTXICON - Displays all icons with codes usable with TYPE POOLS: icon.

3) RS_ABAP_SOURCE_SCAN - Source Scan of Programs

4) RSTXSCRP - Import / Export SAPScripts
     T-Code: /ATL/RSTXSCRP

5) RSBDCCTU - Program for RACOMMIT - Use this program to execute Batch Input Recordings     that contain COMMIT. Use the Queue ID and Recording name after generating Batch Input Session, use those in this program and execute to COMMIT. Ensure to use 'N' for background mode and check RACOMMIT to COMMIT.



6) RSCPSETEDITOR - Default MS Word Editor change - SAPScript and Smartforms
>>> See SAP Note: 791199 for more information

7) SIAC_REGENERATE_TEMPLATES - HTML Templates Regeneration Program

8) SIAC_UPLOAD - Load IAC Objects from File System (Image/MIME Objects Upload for Internet Service)

9) RDDIT076 - Execute this program in SE38 to change the Owner name of the Task

10) RSEIDOCA - I-Doc Monitoring and Auto mailing Program (See Program Information)

11)  RBDMANI2 - I-Doc Reprocessing Status 51 status program

12) RUTATCHK - Alter Table Check - Use this report to check the impact of changing the domain/data element of an existing table in various databases
 

Tuesday, March 10, 2015

AL11 Log Deletion

Aim:
    To delete files in AL11 based on date range.

Program:

REPORT al11_log_deletion.

*==================
* Data Declarations
*==================
TYPE-POOLSicon.
* For Standard Program RSWATCH0 Data
DATAi_outtab  TYPE STANDARD TABLE OF cst_rswatch01_alv,
      wa_outtab TYPE cst_rswatch01_alv,
      g_fname   TYPE char80 VALUE '(RSWATCH0)GT_OUTTAB'.
FIELD-SYMBOLS <fs_outtab> TYPE STANDARD TABLE.

* Structure for Directory Name
TYPESBEGIN OF t_outtab1,
        dirname TYPE shvalue_d,
       END OF t_outtab1.

* Declaration of variables for FM - F4IF_INT_TABLE_VALUE_REQUEST
DATAi_outtab1   TYPE STANDARD TABLE OF t_outtab1,
      wa_outtab1   TYPE t_outtab1,
      i_return LIKE ddshretval OCCURS WITH HEADER LINE.

* Declarations for getting files' info from directory
DATAi_filed TYPE TABLE OF /sdf/file,
      wa_filed TYPE /sdf/file,
      g_dname TYPE epsf-epsdirnam."/sdf/file-name.


* Declarations for the final table that will hold the required files' details for output
TYPESBEGIN OF t_changing,
        name TYPE /sdf/file-name,
        type TYPE /sdf/file-type,
        size TYPE /sdf/file-len,
        date TYPE /sdf/file-mod_date,
        time TYPE /sdf/file-mod_time,
       END OF t_changing.

* Final Internal Table
DATA:  i_ft TYPE TABLE OF t_changing,
       wa_ft TYPE t_changing.
 
DATAl_pos TYPE i,                             " Used to find the file name
      l_strln TYPE i,                           " String length of l_rev
      l_rev TYPE cst_rswatch01_alv-dirname,     " Reversed string which has directory and file
      l_file1 TYPE cst_rswatch01_alv-dirname,   " Reversed file name
      l_file2 TYPE cst_rswatch01_alv-dirname,   " File name
      l_dir TYPE epsf-epsdirnam,                " Reversed directory
      l_fdir TYPE epsf-epsdirnam.               " Directory

* Deletion final path
DATAl_path TYPE cst_rswatch01_alv-dirname.
DATAl_answer(1TYPE c,
      l_records TYPE string,
      l_text TYPE string.

* Inputs
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
  PARAMETERSp_dir TYPE epsf-epsdirnam LOWER CASE DEFAULT '/data' OBLIGATORY.
  SELECT-OPTIONSs_date FOR sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

*======================
* Initialization Event
*======================
INITIALIZATION.

* Fetch Directory Names from RSWATCH0
  PERFORM main IN PROGRAM rswatch0.

  ASSIGN (g_fnameTO <fs_outtab>.

  CHECK sy-subrc EQ 0.

  i_outtab <fs_outtab>.

* Move the fetched directory names from I_OUTTAB to I_OUTTAB1 which supports Search Help logic
  LOOP AT i_outtab INTO wa_outtab.
    IF wa_outtab-dirname+0(5'/data'.
      wa_outtab1-dirname wa_outtab-dirname.
      APPEND wa_outtab1 TO i_outtab1.
      CLEARwa_outtab1wa_outtab.
    ENDIF.
  ENDLOOP.

*=============================
* At Selection-screen event
*=============================

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dir.
  CLEARi_return.
* Function Module for F4 Help
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        'DIRNAME'
      dynpprog        sy-cprog
      dynpnr          sy-dynnr
      dynprofield     'P_DIR'
      value_org       'S'
    TABLES
      value_tab       i_outtab1
      return_tab      i_return
    EXCEPTIONS
      parameter_error 1
      no_values_found 2
      OTHERS          3.

  IF sy-subrc 0.
    p_dir i_return-fieldval.
  ENDIF.

AT SELECTION-SCREEN ON p_dir.
  IF p_dir IS NOT INITIAL.
    IF p_dir+0(5<> '/data'.
      MESSAGE text-102 TYPE 'E'.
    ENDIF.
  ENDIF.

  READ TABLE i_outtab1 WITH KEY dirname p_dir TRANSPORTING NO FIELDS.
  IF sy-subrc <> 0.

* Reversing the input (p_dir)
    CALL FUNCTION 'STRING_REVERSE'
      EXPORTING
        string    p_dir
        lang      sy-langu
      IMPORTING
        rstring   l_rev
      EXCEPTIONS
        too_small 1
        OTHERS    2.

    IF sy-subrc 0.
      FIND FIRST OCCURRENCE OF '/' IN l_rev MATCH OFFSET l_pos.
      IF l_pos <> 0.
        l_file1 l_rev+0(l_pos).
        l_strln strlenl_rev ).
        l_dir l_rev+l_pos(l_strln).

* To get the file name
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string    l_file1
            lang      sy-langu
          IMPORTING
            rstring   l_file2
          EXCEPTIONS
            too_small 1
            OTHERS    2.
        IF sy-subrc <> 0.
          MESSAGE text-103 TYPE 'E'.
        ENDIF.

* To get the directory
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string    l_dir
            lang      sy-langu
          IMPORTING
            rstring   l_fdir
          EXCEPTIONS
            too_small 1
            OTHERS    2.

        IF sy-subrc 0.
          g_dname l_fdir.
        ENDIF.
      ELSE.
        MESSAGE text-102 TYPE 'E'.
      ENDIF.
    ENDIF.
  ELSE.
    g_dname p_dir.
  ENDIF.

*=============================
* Start of Selection event
*=============================
START-OF-SELECTION.

  REFRESHi_fti_filed.

* Function Module to get the files from the specified directory
  PERFORM get_file_attributes.

* Filtering the files based on given date range
  IF l_file2 IS NOT INITIAL.
    LOOP AT i_filed INTO wa_filed WHERE mod_date IN s_date AND
                                        type 'file, regu'.

      IF wa_filed-name CP l_file2.  " Contains Pattern Check
        wa_ft-name wa_filed-name.
        wa_ft-type wa_filed-type.
        wa_ft-size wa_filed-len.
        wa_ft-date wa_filed-mod_date.
        wa_ft-time wa_filed-mod_time.
        APPEND wa_ft TO i_ft.
        CLEARwa_ftwa_filed.
      ENDIF.
    ENDLOOP.
  ELSE.

    LOOP AT i_filed INTO wa_filed WHERE  mod_date IN s_date AND
                                         type 'file, regu'.
      wa_ft-name wa_filed-name.
      wa_ft-type wa_filed-type.
      wa_ft-size wa_filed-len.
      wa_ft-date wa_filed-mod_date.
      wa_ft-time wa_filed-mod_time.
      APPEND wa_ft TO i_ft.
      CLEARwa_ftwa_filed.
    ENDLOOP.
  ENDIF.

* Deletion logic
  IF i_ft IS NOT INITIAL.
    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
        titlebar              text-106
        text_question         text-107
        text_button_1         'Yes'
        icon_button_1         '@B4@'
        text_button_2         'No'
        icon_button_2         '@3U@'
        display_cancel_button ''
        default_button        '2'
      IMPORTING
        answer                l_answer
      EXCEPTIONS
        text_not_found        1
        OTHERS                2.
    IF sy-subrc EQ 0.
      IF l_answer '1'.
        DESCRIBE TABLE i_ft LINES l_records.
        LOOP AT i_ft INTO wa_ft.
          CONCATENATE g_dname '/' wa_ft-name INTO l_path.
          DELETE DATASET l_path.
          CLEARl_path.
        ENDLOOP.
        IF sy-subrc 0.
          l_text text-101.
          REPLACE '&1' WITH l_records INTO l_text.
          MESSAGE l_text TYPE 'S'.
        ENDIF.
      ELSEIF l_answer '2'.
        MESSAGE text-105 TYPE 'I'.
      ENDIF.
    ENDIF.
  ELSE.
    MESSAGE text-104 TYPE 'S' DISPLAY LIKE 'E'.
    STOP.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  GET_FILE_ATTRIBUTES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_file_attributes .

  TABLES epsf.
  DATAi_file_list TYPE TABLE OF epsfili,
        wa_file_list TYPE epsfili.
  DATA l_mtime TYPE DECIMALS 0.
  DATA l_time(10).
  DATA l_date LIKE sy-datum.

  CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
    EXPORTING
      dir_name               g_dname
    TABLES
      dir_list               i_file_list
    EXCEPTIONS
      invalid_eps_subdir     11
      sapgparam_failed       12
      build_directory_failed 13
      no_authorization       14
      read_directory_failed  17
      too_many_read_errors   22
      empty_directory_list   23.

  IF sy-subrc NE 0.
    MESSAGE text-104 TYPE 'S' DISPLAY LIKE 'E'.
    STOP.
  ENDIF.

  IF i_file_list IS NOT INITIAL.
    LOOP AT i_file_list INTO wa_file_list.
      CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
        EXPORTING
          file_name              wa_file_list-name
          dir_name               g_dname
        IMPORTING
          file_size              epsf-epsfilsiz
          file_owner             epsf-epsfilown
          file_mode              epsf-epsfilmod
          file_type              epsf-epsfiltyp
          file_mtime             l_mtime
        EXCEPTIONS
          read_directory_failed  1
          read_attributes_failed 2
          OTHERS                 3.

      IF sy-subrc EQ 0.
        PERFORM p6_to_date_time_tz(rstr0400USING l_mtime
                                                   l_time
                                                   l_date.
        wa_filed-name wa_file_list-name.
        wa_filed-type epsf-epsfiltyp.
        wa_filed-len epsf-epsfilsiz.
        wa_filed-mtime l_mtime.
        wa_filed-mod_date l_date.
        wa_filed-mod_time l_time.
        APPEND wa_filed TO i_filed.
        CLEAR wa_filed.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " GET_FILE_ATTRIBUTES

Text Elements:
101    &1file(s) deleted successfully
102    Enter a valid directory name starting with ''/data''
103    File name reversal not successful
104    No file found
105    Deletion Cancelled
106    Files' Deletion Confirmation
107    Are you sure you want to delete the file(s)?


Selection Texts:
P_DIR    Path
S_DATE    Date Range 

Monday, March 9, 2015

Report to create Support Tickets in Solution Manager using BAPI_NOTIFICATION_CREATE

Points to understand:
1) Go to table CRMD_ORDERADM_H and give old process type as 'SLFN' to see the old data.
2) New Process type is 'ZMIN'. Support Tickets will be created under new process type.
3) Use Transaction Code: SM_CRM to see the Incident. Give the Object ID generated in CRMD_ORDERADM_H for 'ZMIN' Process Type through the below program to see the Support Ticket Details.

REPORT  zag_support.

*--Data Declarations
TABLEScrmd_orderadm_h.

*--BAPI related data
TYPESBEGIN OF bapi_notif_ext_type,
         numb(12TYPE c,
         refnum(20TYPE c,
         type_notif(6TYPE c,
         category(12TYPE c,
         subject(60TYPE c,
         priority(1TYPE c,
         language TYPE lang,
       END OF bapi_notif_ext_type,

       BEGIN OF bapi_notif_crm_type,
         code(4TYPE c,
         codegroup(8TYPE c,
         category(3TYPE c,
       END OF bapi_notif_crm_type,

       BEGIN OF bapi_notif_p_ext_type,
         parnr(12TYPE c,
         type_par(2TYPE c,
         func_par(2TYPE c,
         par_active(1TYPE c,
       END OF bapi_notif_p_ext_type,

       BEGIN OF bapi_notif_n_ext_type,
         type_note(4TYPE c,
         ident(30TYPE c,
         description(60TYPE c,
       END OF bapi_notif_n_ext_type,

       BEGIN OF bapi_notif_s_ext_type,
         instn(10TYPE c,
         mnumm(24TYPE n,
         mstat(1TYPE c,
         comp(20TYPE c,
         ossys(30TYPE c,
         dbsys(30TYPE c,
         front(30TYPE c,
         swcomp(30TYPE c,
         swrel(10TYPE c,
         swptch(10TYPE c,
         add_swcomp(1TYPE c,
         systype(1TYPE c,
         sysid(8TYPE c,
         mandt(3TYPE c,
         sap_tstmp(8TYPE DECIMALS 0,
         s2sap_tstmp(8TYPE DECIMALS 0,
         rel_sap_tstmp(8TYPE DECIMALS 0,
         solnumb(15TYPE n,
         busprocobj1(10TYPE n,
         busprocobj2(10TYPE n,
         busprocobj3(10TYPE n,
         busprocobj4(10TYPE n,
         busprocobj5(10TYPE n,
         swcomponent1(10TYPE n,
         swcomponent2(10TYPE n,
         swcomponent3(10TYPE n,
         swcomponent4(10TYPE n,
         swcomponent5(10TYPE n,
         projectnumb(10TYPE c,
         rolloutphase(10TYPE n,
         sessino_src(13TYPE c,
         sessitype_src(2TYPE c,
         sessino_trg(13TYPE c,
         sessitype_trg(2TYPE c,
         s2sap_first(8TYPE DECIMALS 0,
         s2sap_last(8TYPE DECIMALS 0,
         sfrsap_first(8TYPE DECIMALS 0,
         sfrsap_last(8TYPE DECIMALS 0,
         time_at_sdesk TYPE int4,
         time_at_sap TYPE int4,
         step1(10TYPE n,
         step2(10TYPE n,
         step3(10TYPE n,
         step4(10TYPE n,
         step5(10TYPE n,
         sysno(18TYPE c,
       END OF bapi_notif_s_ext_type,

       BEGIN OF bapi_text_header_ext_type,
         txt_num(4TYPE n,
         language TYPE lang,
         type_text(2TYPE c,
         timestamp(8TYPE DECIMALS 0,
         last_usr(12TYPE c,
       END OF bapi_text_header_ext_type,

       BEGIN OF bapi_text_lines_ext_type,
         txt_num(4TYPE n,
         tdformat(2TYPE c,
         tdline(132TYPE c,
       END OF bapi_text_lines_ext_type,

       BEGIN OF bapi_notif_appx_type,
         descr(60TYPE c,
         appxno(4TYPE n,
         filetyp(3TYPE c,
         filenam(128TYPE c,
         filelen(12TYPE n,
         firstl(8TYPE n,
         lastl(8TYPE n,
         filefm_ul(3TYPE c,
         timestamp(8TYPE DECIMALS 0,
         last_usr(12TYPE c,
         objkey(70TYPE c,
       END OF bapi_notif_appx_type,

       BEGIN OF bapi_notif_soli_type,
         line(255TYPE c,
       END OF bapi_notif_soli_type,

       BEGIN OF bapi_notif_solix_type,
         line(255TYPE x,
       END OF bapi_notif_solix_type.

*--Other types
TYPESBEGIN OF t_tvarvc,
         name              TYPE tvarvc-name,
         low               TYPE tvarvc-low,
       END OF t_tvarvc.

TYPESBEGIN OF ty_service,
        guid TYPE crmt_object_guid,
        component TYPE /aicrm/dtel001c,
       END OF ty_service,

       BEGIN OF ty_text,
         guid TYPE crmt_object_guid,
         text TYPE string,
       END OF ty_text.

TYPESBEGIN OF ty_activity,
        guid TYPE crmt_object_guid,
        priority TYPE crmt_priority,
       END OF ty_activity.

TYPESBEGIN OF ty_crby,
        crby(20TYPE c,
       END OF ty_crby.
TYPESBEGIN OF ty_but000,
        partner TYPE bu_partner,
        bu_sort1 TYPE bu_sort1,
       END OF ty_but000.

TYPESBEGIN OF ty_final,
        guid TYPE crmt_object_guid,
        bpno TYPE crmt_created_by,
        priority TYPE crmt_priority,
        text TYPE string,
        description TYPE crmt_process_description,
        component TYPE /aicrm/dtel001c,
       END OF ty_final.

DATAit_final TYPE TABLE OF ty_final,
      wa_final TYPE ty_final.

DATAit_service TYPE TABLE OF ty_service,
      wa_service TYPE ty_service.

DATAit_text TYPE TABLE OF ty_text,
      it_text_text TYPE TABLE OF ty_text,
      wa_text_text TYPE ty_text,
      wa_text TYPE ty_text.

DATAit_notif_ext TYPE bapi_notif_ext_type,
      it_notif_crm TYPE bapi_notif_crm_type,

      it_text_line TYPE TABLE OF bapi_text_lines_ext_type,
      wa_text_line TYPE bapi_text_lines_ext_type,

      it_partners TYPE TABLE OF bapi_notif_p_ext_type,
      wa_partners TYPE bapi_notif_p_ext_type,

      it_sap_data TYPE TABLE OF bapi_notif_s_ext_type,
      wa_sap_data TYPE bapi_notif_s_ext_type,

      su_number TYPE bapi_notif_ext_type-refnum,

      it_appx_headers TYPE TABLE OF bapi_notif_appx_type,
      wa_appx_headers TYPE bapi_notif_appx_type,

      it_appx_lines TYPE TABLE OF bapi_notif_soli_type,
      wa_appx_lines TYPE bapi_notif_soli_type,

      it_appx_lines_bin  TYPE TABLE OF bapi_notif_solix_type,
      wa_appx_lines_bin  TYPE bapi_notif_solix_type,

      it_notif_notes TYPE TABLE OF bapi_notif_n_ext_type,
      wa_notif_notes TYPE bapi_notif_n_ext_type,

      it_notif_text_headers TYPE TABLE OF bapi_text_header_ext_type,
      wa_notif_text_headers TYPE bapi_text_header_ext_type.


DATAit_crmd TYPE TABLE OF crmd_orderadm_h,
      wa_crmd TYPE crmd_orderadm_h.

DATA l_timestamp TYPE tzntstmpl,
       l_timestamp1 TYPE tzonref-tstamps,
       l_seconds TYPE i.

DATA:  i_tvarvc  TYPE TABLE OF t_tvarvc,
       wa_tvarvc TYPE t_tvarvc.

DATAlt_text_all TYPE comt_text_textdata_t.

DATAit_activity TYPE TABLE OF ty_activity,
      wa_activity TYPE ty_activity.
FIELD-SYMBOLS<ls_textdata> LIKE LINE OF lt_text_all.

DATA:    lt_text_table   TYPE string_table,
         lv_string TYPE string,
         lv_flag(1) TYPE c.
DATAit_crby TYPE TABLE OF ty_crby,
      wa_crby TYPE ty_crby.
DATAit_but000 TYPE TABLE OF ty_but000,
      wa_but000 TYPE ty_but000.

CONSTANTSc_crlf        TYPE abap_cr_lf VALUE cl_abap_char_utilities=>cr_lf.

START-OF-SELECTION.

* Get the Date & Time Range
  CONVERT DATE sy-datum TIME sy-uzeit
      INTO TIME STAMP l_timestamp1 TIME ZONE sy-zonlo.

* Get the time period from TVARVC
  SELECT name low
     FROM tvarvc
     INTO TABLE i_tvarvc
     WHERE  name 'Z_SRVDSK_WO_COMP_TIMEFRAME'
          OR name 'Z_SRVDSK_WO_COMP_EMAIL'.

  IF sy-subrc 0.
    READ TABLE i_tvarvc
             INTO wa_tvarvc
             WITH KEY name 'Z_SRVDSK_WO_COMP_TIMEFRAME'.
    IF sy-subrc 0.
      l_seconds wa_tvarvc-low.
    ENDIF.
  ENDIF.
  IF l_seconds IS NOT INITIAL.
    CALL METHOD cl_abap_tstmp=>subtractsecs
      EXPORTING
        tstmp   l_timestamp1
        secs    l_seconds
      RECEIVING
        r_tstmp l_timestamp.
  ENDIF.
*--Data Fetching
  SELECT FROM crmd_orderadm_h
     INTO TABLE it_crmd
     WHERE process_type 'SLFN' AND
           created_at BETWEEN l_timestamp AND l_timestamp1.

  IF it_crmd IS NOT INITIAL.
*--Fetching of BP No. from BUT000
    LOOP AT it_crmd INTO wa_crmd.
      wa_crby-crby wa_crmd-created_by.
      APPEND wa_crby TO it_crby.
      CLEAR wa_crby.
    ENDLOOP.

    SELECT partner
           bu_sort1
           FROM but000
           INTO TABLE it_but000
           FOR ALL ENTRIES IN it_crby
           WHERE bu_sort1 it_crby-crby.

*--Fetching Component from CRMD_SERVICE_H by passing the above GUIDs
    SELECT guid
           /aicrm/sap_comp
           FROM crmd_service_h
           INTO TABLE it_service
           FOR ALL ENTRIES IN it_crmd
           WHERE guid it_crmd-guid.

*--Fetching priorities for all GUIDs
    SELECT guid
           priority
           FROM crmd_activity_h
           INTO TABLE it_activity
           FOR ALL ENTRIES IN it_crmd
           WHERE guid it_crmd-guid.
  ENDIF.

*--Fetching Text for all GUIDs
  LOOP AT it_crmd INTO wa_crmd.
    CLEAR lv_flag.
    CALL FUNCTION 'CRM_DNO_READ_ORDER_TEXT'
      EXPORTING
        iv_header_guid wa_crmd-guid
      IMPORTING
        et_alltexts    lt_text_all.
    LOOP AT lt_text_all ASSIGNING <ls_textdata>.
      CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
        EXPORTING
          language     sy-langu
          lf           'X'
        IMPORTING
          stream_lines lt_text_table
        TABLES
          itf_text     <ls_textdata>-lines.
      LOOP AT lt_text_table INTO lv_string.
        DATAlv_l1 TYPE string.
        DO.
          IF strlenlv_string 130.
            lv_l1 lv_string+0(130).
            CONCATENATE wa_text-text lv_l1 INTO wa_text-text SEPARATED BY c_crlf.
            SHIFT lv_string BY 130 PLACES LEFT.
            CLEAR lv_l1.
          ELSE.
            lv_l1 lv_string.
            CONCATENATE wa_text-text lv_l1 INTO wa_text-text SEPARATED BY c_crlf.
            CLEAR lv_l1.
            EXIT.
          ENDIF.
        ENDDO.
      ENDLOOP.
IF lv_flag IS INITIAL.
CONCATENATE wa_text-text c_crlf c_crlf 'System Details:' c_crlf INTO wa_text-text.
lv_flag = 'X'.
ENDIF.

    ENDLOOP.
    wa_text-guid wa_crmd-guid.
    APPEND wa_text TO it_text.
    CLEAR wa_text.
  ENDLOOP.


*--Bringing all necessary details to it_final
  SORT it_crmd BY guid.
  LOOP AT it_crmd INTO wa_crmd.
    READ TABLE it_service INTO wa_service
                          WITH KEY guid wa_crmd-guid.
    IF sy-subrc EQ 0.
      READ TABLE it_activity INTO wa_activity
                             WITH KEY guid wa_crmd-guid.
      IF sy-subrc EQ 0.
        READ TABLE it_text INTO wa_text
                           WITH KEY guid wa_crmd-guid.
        IF sy-subrc EQ 0.
          READ TABLE it_but000 INTO wa_but000
                               WITH KEY bu_sort1 wa_crmd-created_by.
          IF sy-subrc EQ 0.
            wa_final-guid wa_crmd-guid.
            wa_final-bpno wa_but000-partner.
            wa_final-priority wa_activity-priority.
            wa_final-text wa_text-text.
            wa_final-description wa_crmd-description.
            wa_final-component wa_service-component.
            APPEND wa_final TO it_final.
            CLEAR wa_final.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.

*--Final assembly and BAPI process
  LOOP AT it_final INTO wa_final.

*--Collecting values to pass to BAPI
*--For IT_NOTIF_EXT
    it_notif_ext-subject wa_final-description.
    it_notif_ext-priority wa_final-priority.
    it_notif_ext-type_notif 'ZMIN'.
    it_notif_ext-language 'E'.

*--For IT_NOTIF_CRM

*--For IT_PARTNERS
    wa_partners-parnr wa_final-bpno.
    wa_partners-type_par 'BP'.
    wa_partners-func_par 'RP'.
    APPEND wa_partners TO it_partners.
    CLEAR wa_partners.

*--For IT_NOTIF_NOTES


*--For IT_SAP_DATA
    wa_sap_data-instn '0020211464'.
    wa_sap_data-comp =  wa_final-component.
    wa_sap_data-swcomp 'SAP_BASIS'.
    wa_sap_data-ossys 'AIX 5.3'.
    wa_sap_data-dbsys 'ORACLE 10.2.0.2.0'.
    wa_sap_data-swrel '700'.
    wa_sap_data-swptch '0008'.
    wa_sap_data-systype 'T'.
    wa_sap_data-mandt '200'.
    wa_sap_data-sysid 'SP1'.
    APPEND wa_sap_data TO it_sap_data.
    CLEAR wa_sap_data.

*--For IT_NOTIF_TEXT_HEADERS
    wa_notif_text_headers-txt_num ='0001'.
    wa_notif_text_headers-language ='EN'.
    wa_notif_text_headers-type_text ='99'.
    wa_notif_text_headers-last_usr '3P_PRAKASHN'.
    APPEND wa_notif_text_headers TO it_notif_text_headers.
    CLEAR wa_notif_text_headers.

*--For IT_TEXT_LINE
    TYPESBEGIN OF lala,
            text(132TYPE c,
          END OF lala.
    DATAlt_split TYPE TABLE OF lala,
          wa_split TYPE lala.
    SPLIT wa_final-text AT c_crlf INTO TABLE lt_split.
    REFRESH it_text_line.
    LOOP AT lt_split INTO wa_split.
      wa_text_line-tdline wa_split-text.
      wa_text_line-txt_num '0001'.
      wa_text_line-tdformat '/'.     " For new line
      APPEND wa_text_line TO it_text_line.
      CLEAR wa_text_line.
    ENDLOOP.

*--Support Message Creation using BAPI
    CALL FUNCTION 'BAPI_NOTIFICATION_CREATE'
      EXPORTING
        notif_ext          it_notif_ext           "Has values
        notif_crm          it_notif_crm           "Has values
      TABLES
        notif_partners     it_partners            "Has values
        notif_notes        it_notif_notes
        notif_sap_data     it_sap_data            "Has values
        notif_text_headers it_notif_text_headers  "Has values
        notif_text_lines   it_text_line           "Has values
        appx_headers       it_appx_headers
        appx_lines         it_appx_lines
        appx_lines_bin     it_appx_lines_bin.
    IF sy-subrc EQ 0.
      REFRESHit_partnersit_sap_datait_notif_text_headersit_text_line.
      CLEARit_notif_extit_notif_crm.
    ENDIF.
  ENDLOOP.
  MESSAGE 'Tickets'' creation successful' TYPE 'S'.