12-30-2013 10:32 AM
Hello Everyone,
I have three internal tables with me.
HEADER_T : Contains Header level data.
DETAILED_T : Contains the Detailed Data.
FIELDS_T : Contains the field names with which mapping is to be done for the above two levels.
What I need to do is for each entry of HEADER_T , I need to fetch corresponding entries in DETAILED_T comparing on fields mentioned in FIELDS_T.
For Example:
HEADER_T
A P AT
A1 P1 20
A1 P2 10
A2 P1 30
DETAILED_T.
A P E T
A1 P1 E1 5
A1 P1 E2 5
A1 P1 E3 5
A1 P1 E4 5
A1 P2 E1 5
A1 P2 E2 5
A2 P2 E1 20
A2 P2 E2 10
FIELDS_T
FNAME:
A
P
So here for 1st entry in HEADER_T we get 4 entries in DETAILED_T using the fields of table FIELDS_T
Kindly give your inputs.
Thanks & Regards,
Rohit.
12-30-2013 11:21 AM
Hello Rohit,
One way to do this would be by using ASSIGN & dynamic where clause:
LOOP at header_t ASSIGNING <header>.
WRITE: / <header>-a, <header>-p. SKIP.
LOOP at fields_t ASSIGNING <fields>.
ASSIGN COMPONENT fname OF STRUCTURE <header> to <comp>.
IF sy-subrc = 0.
IF sy-tabix = 1.
l_where = <fields>-fname && ` = ` && '''' && <comp> && ''''.
ELSE.
l_where = l_where && ` AND ` && <fields>-fname && ` = ` && '''' && <comp> && ''''.
ENDIF.
ENDIF.
ENDLOOP.
LOOP at detailed_t ASSIGNING <detail> WHERE (l_where).
WRITE: ` `, <detail>-a, <detail>-p, <detail>-e.
ENDLOOP.
SKIP 2.
ENDLOOP.
Cheers,
Manu.
12-30-2013 11:24 AM
line 09 is trucated... This editor sucks really
so 09 should ends with && ''''.
Br,
Manu.
12-30-2013 11:51 AM
Thank you Manu,
Seems like the solution should work.
I will try and get back
Thanks
12-30-2013 10:06 PM
Hope this would work.
In case of any issues, do revert. I have a backup solution.