Sending Data Target, Data at the Receiver Port using IDOC as an Interface Using ABAP Program
- Requirement
We want to fetch the data from a Data Target – Cube and send it to the receiver system through IDOC.So we have filter the require fields from the Cube which we want and created a Customise ABAP program which has a selection criteria. Base on the selection criteria, data gets passed to an internal table and then get formatted into IDOC segment type .IDOC is been created with help of FM – MASTER_IDOC_DISTRIBUTE by passing master IDOC control (Sender and Receiver information), master IDOC Data contain data which has to pass and communication IDOC Control in which IDOC no. is been created.
- Preparation
a) Creation of IDOC Type – ZFIN_FIGLMAP
Using Tcode – WE30 we can create an IDOC Type with a Development Object (Basic Type)
b) Message Type – ZBD_JUP_ACORN_MSG
Using Tcode – WE81 we can create a Message Type.
c) Segment Type
Using Tcode – WE31 we can create a Segment Type. It is nothing but the field structure or format to pass the data. Three segment type has been created as per the requirement
1. ZFI_ACORN_HDR
1. 2. ZFI_ACORN_ITM
1. 3. ZFI_ACORN_TLR
d) Assigning IDOC Type to Message Type
Using Tcode – WE82 we assign Message Type to IDOC Type.
e) Partner Profile Creation – ACORN
Using Tcode – We20 we can create Partner no.(ACORN) and Partner Type(LS). In this we are assigning message type to outbound parameter.
3. Fetching the data :
In ACRON interface the data is been fetch from the Cube (cube_test1) as a source. We are using only those fields which are used for ACRON interface.
4. Selection Criteria :
We are using Fiscal year/Period, Acorn GL code and Company Code (Mandatory). Based on these selection criteria the data gets fetch from the cube and then IDOC is been created with the define records as in Packet Size.
5. Execution Process
When the program is been executed with the selection criteria the following 2 pop up screen will be process
a) Below screen pop up when IDOC has been selected and process at the port successfully which is done by using SUBMIT with program name via selection screen ( which will the IDOC no. Generated by using FM MASTER_IDOC_DISTRIBUTE )
seltab_wa-selname = ‘DOCNUM’.
seltab_wa-sign = ‘I’.
seltab_wa-option = ‘EQ’.
seltab_wa-low = gen_idoc-docnum.
append seltab_wa to seltab.
submit RSEOUT00 AND RETURN with selection-table seltab.
b) Display the number of an IDOC which has been created using
CONCATENATE gen_idoc-docnum ‘IDOC has been Generated’ INTO gen_message SEPARATED BY space.
MESSAGE gen_message TYPE ‘I’.
We can view the IDOC with Transaction code WE05 and in that please give the IDOC no. and execute as shown below
In the following 3 screen’s shot data gets populated in Header, Details and Footer Segment Type with Status 03 (Data passed to port OK). On the right hand side of each screen we can see the Fields names and Field contents.
Total no of records are 9. Details segment Type contain 7 records with one header and one footer record common for all.
a) Header Data
b) Details Data
c) Footer Data
Now these data been import or pull at receiver side through SAP or Non SAP System.
6. Program Logic
Step1: Create an Internal table for only those fields which we want from the Source Cube and then used below FM to read data from Cube
CALL FUNCTION ‘RSDRI_INFOPROV_READ’
EXPORTING
i_infoprov = ‘cube_test1’
i_th_sfc = lt_ch
i_th_sfk = lt_kf
i_packagesize = lv_packet
i_t_range = lt_sel
IMPORTING
e_t_data = lt_data
e_end_of_data = lv_end_of_data
Exporting Parameters
i_th_sfc is the Field Catalog for Charateristics Fields for which we have to fetch the data from the Cube
e.g. CLEAR lw_ch.
lw_ch-chanm = ‘0COMP_CODE’.
lw_ch-chaalias = ‘COMP_CODE’.
lw_ch-orderby = 15.
INSERT lw_ch INTO TABLE lt_ch.
i_th_sfk is the Field Catalog for Key Figure Fields for which we have to fetch the data from the Cube
e.g. CLEAR lw_kf.
lw_kf-kyfnm = ‘OKBD_AMCP’.
lw_kf-kyfalias = ‘/BIC/OKBD_AMCP’.
lw_kf-aggr = ‘SUM’.
INSERT lw_kf INTO TABLE lt_kf.
i_packagesize is packet size to fetch no. of records
i_t_range is selection criteria for the cube
e.g.
READ TABLE so_ccode INDEX 1.
CLEAR lw_sel.
lw_sel-chanm = ‘0COMP_CODE’.
lw_sel-sign = ‘I’.
lw_sel-compop = ‘EQ’.
lw_sel-low = so_ccode-low.
APPEND lw_sel TO lt_sel.
Importing Parameters
e_t_data contains the data of cube in the required internal table as define.
e_end_of_data This parameter indicates whether the data package returned to E_T_DATA.E_T_DATA is the last one.
Step 2: Now we can create IDOC Control and as well as divided the data as we have to send it through IDOC, based on three segment type Header (ZFI_ACORN_HDR), Details (ZFI_ACORN_ITM) and Footer (ZFI_ACORN_TLR) as shown in figure 2 (c). So based on these three segment type we have created 3 internal tables as header table, Details table and Footer table.
IDOC Control
****sender
p_edidc-sndpor = ‘SAPRD7’. ” Port
p_edidc-sndprt = ‘LS’. ” Partner type
p_edidc-sndprn = ‘RD7-300’. ” Partner number* Receiver
p_edidc-rcvpor = ‘DER010’. ” Port
p_edidc-rcvprn = ‘INTETR’. ” Partner number
p_edidc-rcvprt = ‘LS’. ” Partner type
IDOC Control contains sender and receiver information
Header – ZFI_ACORN_HDR
wa_acorn_copa_header-identifier = ‘HDR’.
wa_acorn_copa_header-zz_ic_intid = ‘COPA_Data’.
wa_acorn_copa_header-blart = ‘SP’.
wa_acorn_copa_header-bukrs = so_ccode-low.
wa_acorn_copa_header-bldat = ‘20120930’.
wa_acorn_copa_header-budat = ‘20120930’.
APPEND wa_acorn_copa_header TO i_acorn_copa_header.
LOOP AT i_acorn_copa_header INTO wa_acorn_copa_header.
wa_idc_data-segnam = ‘ZFI_ACORN_HDR’.
MOVE wa_acorn_copa_header TO wa_idc_data-sdata.
APPEND wa_idc_data TO idc_data.
ENDLOOP.
We have appended Segment type header into idc_data internal table with data.
Details – ZFI_ACORN_ITM
LOOP AT lt_data INTO lw_data..
wa_idc_data-segnam = ‘ZFI_ACORN_ITM’.
wa_acorn_copa_details-acnidentifier = ‘DET’.move lw_data-post_key to wa_acorn_copa_details-acnnewbs.move lw_data-/bic/zacrnglcd to wa_acorn_copa_details-acnnewko.move lw_data-/bic/zacrbrand to wa_acorn_copa_details-acnrke_wwbrd.MOVE lw_data-/bic/zacrnpctr TO wa_acorn_copa_details-acnprctr.
MOVE wa_acorn_copa_details TO wa_idc_data-sdata.
APPEND wa_idc_data TO idc_data.
Endloop.
We have appended Segment type Details into idc_data internal table with data.
Footer – ZFI_ACORN_TLR
wa_acorn_copa_footer-identifier = ‘FTR’.
wa_acorn_copa_footer-totnorec = lines_count.
CONCATENATE
wa_acorn_copa_footer-identifier
wa_acorn_copa_footer-totnorec
INTO wa_idc_data-sdata RESPECTING BLANKS.
APPEND wa_idc_data TO idc_data
We have appended Segment type Footer into idc_data internal table with data.
Step 3: we have used FM – MASTER_IDOC_DISTRIBUTE to create and IDOC passing as an input parameter as IDOC Control (master_idoc_control) and IDC Data (master_idoc_data ). IDOC no. is generated in communication_idoc_control table which we can view in WE05 Tcode as shown in figure for Execution Process (5) above.
nice one 🙂
I have perceived more information about IDOCS from this posting,please share more.
nice one