Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Reading IDOC data

Former Member
0 Likes
1,421

Hi folks,

I have read an IDOC into an internal table int_edidd using FM Idoc_Read_Completely......

Now i want to read the data from Field int_ediddsdata to perform validations ...is there any standard FM available for this??

3 REPLIES 3
Read only

Former Member
0 Likes
761

LOOP AT idoc_contrl.

LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.

CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.

  • Examine Idoc Segment

CASE idoc_data-segnam.

WHEN 'ZSEG1'.

WHEN 'ZSEG2'.

CLEAR wa_zseg2.

wa_zseg2 = idoc_data-sdata.

APPEND wa_zseg2 TO i_zseg2.

ENDCASE.

ENDCATCH.

  • Check catch result

IF sy-subrc <> 0.

<ur code>

ENDIF

ENDLOOP.

ENDLOOP.

i dont think there is any FM for this. See the code above which i had used. once u get the idoc data in internal tables u ll have to extract ur fields from sdata and perform ur validations.

Read only

0 Likes
761

Thanx Rahul...

Any more inputs guys...

Read only

0 Likes
761

Now to populate the new field you have to code inside the exit as follows:

1. Loop the Idoc data table

2. Put a case...endcase statement to Identify the segmentname .

3. When the segment name(SEGNAM) you add the new fields.

4. Move the segmentdata (SDATA) into a workarea of the same type of the segment

5. Populate the newvalues in the spcific field of the work area

6. Move the workarea to the segment data (SDATA)

7. Now modify the Idocdata table with its workarea to reflect the new field in the idocdata table.

You can refer the following code to understand the process:



LOOP AT lp_pi_idoc_data INTO lw_idoc_data.
 
      lv_index = sy-tabix.
      CASE lw_idoc_data-segnam.
 
        WHEN lc_e1oll02.
 
          MOVE lw_idoc_data-sdata TO lw_e1oll02.
          lw_e1oll02-fld1 = '1234'     "New field populated
          MOVE lw_e1oll02-fld1 to lw_idoc_data-sdata.
 
          MODIFY lp_pi_idoc_data FROM lw_idoc_data INDEX lv_index.
 
      ENDCASE.
    ENDLOOP.