‎2008 Aug 05 4:00 AM
Hi Friends,
I am writing a report to compare the uploaded legacy vendor data with that of existing vendor data in sap.
So one of the comparision is name, i am doing like below.
LOOP AT LT_SAP_DATA INTO LS_SAP_DATA.
IF NOT LS_SAP_DATA-NAME1 IS INITIAL.
CONDENSE LS_SAP_DATA-NAME1 NO-GAPS.
TRANSLATE LS_SAP_DATA-NAME1 TO
LOWER CASE.
READ TABLE LT_LEGACY_DATA INTO
LS_LEGACY_DATA
WITH KEY VENDORNAME = LS_SAP_DATA-NAME1.
IF SY-SUBRC NE 0.
LOOP AT LT_LEGACY_DATA INTO LS_LEGACY_DATA
WHERE VENDORNAME CS LS_SAP_DATA-NAME1.
Here i am capturing based on the comparison.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
but for 15000 legacy data and 15000 SAP data if i am comparing with name, with loop inside loop, its going for time out error.
Is there any better way of doing this other than uploading legacy data in smaller chunks?
Any help on this is highly appreciated.
regards,
Simha
‎2008 Aug 06 4:35 AM
Hello Simha
At least you can do some tuning of your coding which might help to overcome the timeout:
DATA: ld_idx TYPE i,
ld_next TYPE i.
SORT lt_legacy_data BY vendorname. " for BINARY SEARCH
LOOP AT LT_SAP_DATA INTO LS_SAP_DATA
WHERE NOT ( name1 IS INITIAL ).
" IF NOT LS_SAP_DATA-NAME1 IS INITIAL.
CONDENSE LS_SAP_DATA-NAME1 NO-GAPS.
TRANSLATE LS_SAP_DATA-NAME1 TO
LOWER CASE.
READ TABLE LT_LEGACY_DATA INTO
LS_LEGACY_DATA
WITH KEY vendorname = LS_SAP_DATA-NAME1
BINARY SEARCH.
IF SY-SUBRC NE 0.
LOOP AT LT_LEGACY_DATA INTO LS_LEGACY_DATA
WHERE VENDORNAME CS LS_SAP_DATA-NAME1.
"Here i am capturing based on the comparison.
ENDLOOP.
ENDIF.
"ENDIF.
ENDLOOP.
Regards
Uwe
‎2008 Aug 05 4:18 AM
‎2008 Aug 06 2:11 AM
Hi Uwe,
Thanks for that input.
I read the blog from Rob Burbank and was quiet informative, but here in my case i can neither user Parallel cursor or Indexed loop as i am comparing the names with operator 'CS', so i can't neglect already looped iterations by catching the index.
Is there any other efficient way?
Thanks,
Simha
‎2008 Aug 05 4:21 AM
Hi Simha,
You can do this way
LOOP AT LT_SAP_DATA INTO LS_SAP_DATA.
IF NOT LS_SAP_DATA-NAME1 IS INITIAL.
CONDENSE LS_SAP_DATA-NAME1 NO-GAPS.
TRANSLATE LS_SAP_DATA-NAME1 TO
LOWER CASE.
READ TABLE LT_LEGACY_DATA INTO
LS_LEGACY_DATA
WITH KEY VENDORNAME = LS_SAP_DATA-NAME1.
IF SY-SUBRC EQ 0.
Here i am capturing based on the comparison.
ENDIF.
ENDIF.
ENDLOOP.Best regards,
raam
‎2008 Aug 05 5:24 AM
Hi Raam,
there is a small change in my code which i didn't paste earlier.
I am taking if read is successful at fist instance and even if read is unsuccessful then only i am going for nested loop.
LOOP AT LT_SAP_DATA INTO LS_SAP_DATA.
IF NOT LS_SAP_DATA-NAME1 IS INITIAL.
CONDENSE LS_SAP_DATA-NAME1 NO-GAPS.
TRANSLATE LS_SAP_DATA-NAME1 TO
LOWER CASE.
READ TABLE LT_LEGACY_DATA INTO
LS_LEGACY_DATA
WITH KEY VENDORNAME = LS_SAP_DATA-NAME1.
IF SY-SUBRC EQ 0.
Here i am capturing based on the comparison.
ELSE.
LOOP AT LT_LEGACY_DATA_FRMT INTO LS_LEGACY_DATA
WHERE VENDORNAME CS LS_SAP_DATA-NAME1.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
‎2008 Aug 05 5:30 AM
Hi,
This could be useful to u.
Entries: 100 (ITAB1), 1000 (ITAB2)
Line width: 100
Both tables sorted by key K
I = 1.
LOOP AT ITAB1 INTO WA1.
LOOP AT ITAB2 INTO WA2 FROM I.
IF WA2-K <> WA1-K.
I = SY-TABIX.
EXIT.
ENDIF.
" ...
ENDLOOP.
ENDLOOP.
Rgds.,
subash
‎2008 Aug 06 4:35 AM
Hello Simha
At least you can do some tuning of your coding which might help to overcome the timeout:
DATA: ld_idx TYPE i,
ld_next TYPE i.
SORT lt_legacy_data BY vendorname. " for BINARY SEARCH
LOOP AT LT_SAP_DATA INTO LS_SAP_DATA
WHERE NOT ( name1 IS INITIAL ).
" IF NOT LS_SAP_DATA-NAME1 IS INITIAL.
CONDENSE LS_SAP_DATA-NAME1 NO-GAPS.
TRANSLATE LS_SAP_DATA-NAME1 TO
LOWER CASE.
READ TABLE LT_LEGACY_DATA INTO
LS_LEGACY_DATA
WITH KEY vendorname = LS_SAP_DATA-NAME1
BINARY SEARCH.
IF SY-SUBRC NE 0.
LOOP AT LT_LEGACY_DATA INTO LS_LEGACY_DATA
WHERE VENDORNAME CS LS_SAP_DATA-NAME1.
"Here i am capturing based on the comparison.
ENDLOOP.
ENDIF.
"ENDIF.
ENDLOOP.
Regards
Uwe
‎2008 Aug 06 7:59 AM
Thanks Uwe, i will sort and read with binary search but can't loop with where condition as i am having other validations before comparing with Name so have to loop with out any conditions.
Thanks for your help.
I am closing this thread as answered.