2011 Oct 24 6:51 AM
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...
2011 Oct 25 10:02 AM
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.
2011 Oct 24 7:01 AM
May be you can use the combination of functions IDOCTYPE_READ_COMPLETE & IDOC_READ_COMPLETELY
Kesav
2011 Oct 24 10:51 AM
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 ....
2011 Oct 24 11:05 AM
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
2011 Oct 25 10:02 AM
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.
2011 Oct 25 10:24 AM
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
2011 Oct 25 11:07 AM
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....
2011 Oct 25 11:17 AM
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.