‎2021 Nov 10 7:42 PM
DATA : it_review TYPE STANDARD TABLE OF z_review,<br> it_roles TYPE STANDARD TABLE OF z_roles,<br> it_count TYPE STANDARD TABLE OF z_count.<br><br>select * FROM z_review INTO TABLE it_review. "--> count = 22477 Rows<br> select * FROM z_roles INTO TABLE it_roles. "---> count = 858035 ROws <br> select * FROM z_count INTO TABLE it_count. "---->count = 187458 Rows <br><br>*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<br>data(gt_final) = VALUE lt_final( for lt_review in it_review<br> for ls_roles IN it_roles FROM line_index( it_roles[ AGR_NAME = lt_review-AGR_NAME ] )<br> where ( AGR_NAME = lt_review-AGR_NAME )<br> for ls_count in it_count FROM line_index( it_count[ uname = lt_review-uname ] )<br> WHERE ( uname = lt_review-uname and tcode = ls_roles-tcode )<br> LET ls_final = VALUE ty_final(<br> uname = lt_review-uname<br> AGR_NAME = lt_review-AGR_NAME<br> tcode = ls_roles-tcode<br> count = ls_count-zcount )<br> IN ( CORRESPONDING #( BASE ( ls_final ) lt_review ) ) ).<br><br><br> LOOP AT it_review INTO DATA(wa_review).<br>** check if user and tcode has count..<br> LOOP AT it_roles INTO DATA(wa_roles) WHERE agr_name = wa_review-agr_name.<br> TRY .<br> data(wa_count) = it_count[ UNAME = wa_review-uname TCODE = wa_roles-tcode ].<br> CATCH cx_sy_itab_line_not_found..<br> CONTINUE.<br> ENDTRY.<br> write :/10 wa_review-uname ,20 wa_review-agr_name , 60 wa_roles-tcode , 75 wa_count-zcount.<br> exit.<br> endloop.<br> ENDLOOP.<br>
<br>
I need help / suggestion i m trying my hands on 7.4 syntax on SQL 'FOR " multiple joins and trying to check if i replace the nested looped operation , but my Nested FOR never gave the result where as nested Loop did gave output..
can you all help me figure out , where I going completely wrong...
Ask here is - if my FOR nested is wrong or right , how can design it such that it behaves as nested looped and i get final table appended with desired fields .. as i done in the above loop statments.
‎2021 Nov 10 8:24 PM
Edit your question and this time click on the "code" button in the question editor, and enter the code into a code box so that it's readable.
‎2021 Nov 10 8:56 PM
thanks Mathew !! did exactly as asked .
‎2021 Nov 10 8:56 PM
I think it's a better practice to explain the problem before the code.
‎2021 Nov 10 9:04 PM
Your "for" loops look completely different from the second block, I don't understand what you want to achieve.
‎2021 Nov 10 9:04 PM
sandra.rossi - i did mention in the above question , let me know if i need to add more details .. happy to help !!
‎2021 Nov 11 7:03 AM
I don't understand how you came to have a so complex expression. Why not simplifying it:
data(gt_final) = VALUE lt_final(
for wa_review in it_review
for wa_roles IN it_roles
where ( AGR_NAME = wa_review-AGR_NAME )
( uname = wa_review-uname
agr_name = wa_review-agr_name
tcode = wa_roles-tcode
count = VALUE #( it_count[ UNAME = wa_review-uname TCODE = wa_roles-tcode ] OPTIONAL ) ) ).
‎2021 Nov 11 2:42 PM
Thanks sandra.rossi for the code , I need some more help if you can suggest would be great.
in above code you have mentioned 2 FOR statement together with where single clause , does that mean if both are met then only record gets inserted in the GT_FINAL...
‎2021 Nov 11 3:56 PM
Yes. Not different from your 2 LOOP AT.
LOOP AT it_review INTO DATA(wa_review).
LOOP AT it_roles INTO DATA(wa_roles) WHERE agr_name = wa_review-agr_name.
‎2021 Nov 12 2:01 AM
Thanks @sandra rossi - for your help , I will mark it as close ...