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

Fetching segment content in IDOC

Former Member
0 Likes
1,594

Hi,

My idoc segment contains total 16 fields but in those 16 fields I want to pick seventh field value. In the table edid4 the SDATA field contains mixing of all 16 fields data so how to pick seventh field data in that.

Please help me. I will give points.

Thanks a lot in advance.

Hi,

My idoc segment contains total 16 fields but in those 16 fields I want to pick seventh field value. In the table edid4 the SDATA field contains mixing of all 16 fields data so how to pick seventh field data in that.

Please help me. I will give points.

Thanks a lot in advance.

5 REPLIES 5
Read only

former_member404244
Active Contributor
0 Likes
949

Hi,

yes u can get like this..say for example i have a segment which has 5 fields..

1>matnr (18 character)

2>maktx (40 characters)

3>matkl (9 characters)

4>field1 (5 characters)

5>field2 (2 characters)..

if i want third field value i can do this..

v_matkl = i_edidd-sdata+58(9).

58 because,ur matnr has 18 chars and maktx has 40 chars....

try this..

Reward if helpful.

Regards,

Nagaraj

Read only

0 Likes
949

hi,

read SDATA (segment data) into the structure of the same type as the idoc segement and use the field.

If the field number and the idoc type are to be determined dynamically then you have to use field-symbols and use assign component statement.

Regards,

Aj

Message was edited by:

Abhishek Jolly

Read only

Former Member
0 Likes
949

Hi,

Try IDOC_READ_COMPLETELY to read segment and values based on IDoc number.

Sri

Read only

Former Member
0 Likes
949

Babji,

Best way would be declare a variable of type segment and then move data from SDATA to segement variable. So var-field7 ( where as field7--> Sevent field name)

Using this technic you can always read correct field value.

Hope this will help. Let me know if you need more details.

Nilesh

Read only

Former Member
0 Likes
949

Hi Babji, YOu can use the function modules:

1) EDI_DOCUMENT_OPEN_FOR_READ

2) EDI_SEGMENTS_GET_ALL and

3) EDI_DOCUMENT_CLOSE_READ

in the same order:

sample code:

CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_READ'

EXPORTING

DOCUMENT_NUMBER = P_DOCNUM

IMPORTING

IDOC_CONTROL = F_IDOC_CONTROL

EXCEPTIONS

OTHERS = 01.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

RAISING ERROR_OPENING_IDOC.

ENDIF.

  • Read IDOC data segments

CALL FUNCTION 'EDI_SEGMENTS_GET_ALL'

EXPORTING

DOCUMENT_NUMBER = P_DOCNUM

TABLES

IDOC_CONTAINERS = T_IDOC_DATA

EXCEPTIONS

OTHERS = 01.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

RAISING ERROR_READING_IDOC.

ENDIF.

  • Close IDOC

CALL FUNCTION 'EDI_DOCUMENT_CLOSE_READ'

EXPORTING

DOCUMENT_NUMBER = P_DOCNUM

IMPORTING

IDOC_CONTROL = F_IDOC_CONTROL

EXCEPTIONS

OTHERS = 01.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

RAISING ERROR_CLOSING_IDOC.

ENDIF.

Then you can use teh T_idoc_data intermal table to read the element in the segment.

Regards,

Ravi Kanth Talagana