Application Development 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: 

Get the value of a particular field in a segment of an Idoc

Former Member
0 Kudos
2,965

Hi All,

I have a requirement where I need to write a report which will fetch the value of a particular field in a segment of an idoc.

I have the idoc number segment and field name as input parameters by which I can fetch Sdata from EDID4 but the confusion is how to find the exact field value from that Sdata. How to Map the SDATA to the segment structure.

Please advice...

1 ACCEPTED SOLUTION

Former Member
0 Kudos
637

Hi ,

There is a simple way also to do this.

Declare a structure with type the segment name in which the field is present.

Now move sdata to this structure.

You will get all the fields filled with the relevent data in the structure.

regards,

Ganesh.

7 REPLIES 7

kesavadas_thekkillath
Active Contributor
0 Kudos
637

May be you can use the combination of functions IDOCTYPE_READ_COMPLETE & IDOC_READ_COMPLETELY

Kesav

0 Kudos
637

Using IDOC_READ_COMPLETELY, i can get the sdata for a segment. But how to assign that to the segment ...

What I mean is the user will give the segment name as input. So i cannot create a work area for any segment previously.... somehow I need to create a work area of that segment type dynamically to transfer that sdata to that work area. How to achieve that ....

0 Kudos
637

Hi


PARAMETERS:pa TYPE edihsegtyp.

FIELD-SYMBOLS:<fs> TYPE ANY.
DATA:wf_ref TYPE REF TO data.

START-OF-SELECTION.

  CREATE DATA wf_ref TYPE (pa).
  ASSIGN wf_ref->* TO <fs>.
  IF <fs> IS ASSIGNED.
    CALL METHOD cl_abap_container_utilities=>read_container_c
    EXPORTING
    im_ container = sdata
     IMPORTING
    ex_ value = <fs>
    EXCEPTIONS
    illegal_parameter_type = 1
    OTHERS = 2.
  ENDIF.

  WRITE <fs>.

Kesav

Former Member
0 Kudos
638

Hi ,

There is a simple way also to do this.

Declare a structure with type the segment name in which the field is present.

Now move sdata to this structure.

You will get all the fields filled with the relevent data in the structure.

regards,

Ganesh.

0 Kudos
637

Now move sdata to this structure.

You will get all the fields filled with the relevent data in the structure.

Still in non unicode environment ?

Kesav

0 Kudos
637

Hi,

I have one last doubt that may be you people can help with... The user will be giving the segment name and field name as input. So by following Kesav's code while i can get all the values in the segment structure at runtime please suggest how to display any one field from that structure given that that particular field will come at runtime.

EX: user gives an idoc number 123 (say belonging to Orders basic type)

segment E1EDK01

field BELNR.

So i need to display the value of E1EDK01-BELNR of idoc number 123.

Please suggest how to achieve this....

0 Kudos
637

field-symbols:<fs_field> type any.
lv_field = 'BELNR'.
assign component lv_field of structure <fs> to <fs_field>.
if sy-subrc = 0.
write <fs_field>.
endif.