Application Development and Automation 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: 
Read only

Deep for statment

0 Likes
2,407

Hi All ,


I am testing below example found in web .

I am getting no result into lt_final table as there are no values in lt_makt table . Can somebody suggest that how to validate tables are initial or not .

DATA(lt_final) = VALUE ty_t_final( FOR ls_ekpo IN lt_ekpo
FOR ls_ekko IN lt_ekko FROM line_index( lt_ekko[ ebeln = ls_ekpo-ebeln ] )
WHERE ( ebeln = ls_ekpo-ebeln )
FOR ls_makt IN lt_makt FROM line_index( lt_makt[ matnr = ls_ekpo-matnr ] )
WHERE ( matnr = ls_ekpo-matnr )
FOR ls_t001w IN lt_t001w FROM line_index( lt_t001w[ werks = ls_ekpo-werks ] )
WHERE ( werks = ls_ekpo-werks )
LET ls_final = VALUE ty_final(
lifnr = ls_ekko-lifnr
maktx = ls_makt-maktx
name1 = ls_t001w-name1 )
IN ( CORRESPONDING #( BASE ( ls_final ) ls_ekpo ) ) ).

Regards,

Srikanth

Hi All ,


I am testing below example found in web .

I am getting no result into lt_final table as there are no values in lt_makt table . Can somebody suggest that how to validate tables are initial or not .

DATA(lt_final) = VALUE ty_t_final( FOR ls_ekpo IN lt_ekpo
FOR ls_ekko IN lt_ekko FROM line_index( lt_ekko[ ebeln = ls_ekpo-ebeln ] )
WHERE ( ebeln = ls_ekpo-ebeln )
FOR ls_makt IN lt_makt FROM line_index( lt_makt[ matnr = ls_ekpo-matnr ] )
WHERE ( matnr = ls_ekpo-matnr )
FOR ls_t001w IN lt_t001w FROM line_index( lt_t001w[ werks = ls_ekpo-werks ] )
WHERE ( werks = ls_ekpo-werks )
LET ls_final = VALUE ty_final(
lifnr = ls_ekko-lifnr
maktx = ls_makt-maktx
name1 = ls_t001w-name1 )
IN ( CORRESPONDING #( BASE ( ls_final ) ls_ekpo ) ) ).

Regards,

Srikanth

8 REPLIES 8
Read only

michael_piesche
Active Contributor
2,287

Can you be more specific? When or where do you want to check for table with no data and when or where for table with data? And why do you want to do that? Is there a dump? Do you want to skip some statements?

Read only

Sandra_Rossi
Active Contributor
2,287

Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).

Read only

Sandra_Rossi
Active Contributor
2,287

Performance hint: it seems that you tried to implement so-called "parallel cursor" using nested table iterations, but that's slower than doing it with classic ABAP because you cannot exit the loops at "key breaks". This is exactly this kind of situation where so-called "new ABAP" should not be used.

Read only

0 Likes
2,287

Hi All ,

Thank you all for reply so quickly ..i attached the code in notepad .

Here my question is

-> lt_final table is not filling becuase in my system lt_makt is Initial.

I am thinking that lt_fina tab is not filling because lt_makt is initial . is this correct ?.

Is there any way to check lt_makt is not initial or not .


Read only

2,287

Here, so people don't have to download a .txt file. Please, if possible, try to use the 'CODE' button in the future.

TYPES ttt_wa1 TYPE STANDARD TABLE OF ty_wa1 WITH EMPTY KEY.
TYPES ttt_wa2 TYPE STANDARD TABLE OF ty_wa2 WITH EMPTY KEY.


DATA:itab2 TYPE TABLE OF ty_wa1.


DATA(itab1) = VALUE ttt_wa1( ( field1 = 1 field2 = 2 )
                             ( field1 = 1 field2 = 2 ) ).

DATA(target1) = VALUE ttt_wa2( FOR lwa_source IN itab1 ( CORRESPONDING #( lwa_source ) ) ).
 
TYPES: BEGIN OF ty_final,
         ebeln TYPE ebeln,
         ebelp TYPE ebelp,
         lifnr TYPE lifnr,
         matnr TYPE matnr,
         maktx TYPE maktx,
         werks TYPE werks_d,
         name1 TYPE name1,
       END OF ty_final,
       ty_t_final TYPE STANDARD TABLE OF ty_final WITH DEFAULT KEY.

START-OF-SELECTION.
  SELECT * FROM ekko
   UP TO 10 ROWS
    INTO TABLE @DATA(lt_ekko).
  IF sy-subrc = 0.
    SELECT * FROM ekpo
     INTO TABLE @DATA(lt_ekpo)
      FOR ALL ENTRIES IN @lt_ekko
       WHERE ebeln = @lt_ekko-ebeln.
    IF sy-subrc = 0.
      SELECT * FROM makt INTO TABLE @DATA(lt_makt)
       FOR ALL ENTRIES IN @lt_ekpo
        WHERE matnr = @lt_ekpo-matnr
        AND spras = @sy-langu.


      SELECT * FROM t001w INTO TABLE @DATA(lt_t001w)
         FOR ALL ENTRIES IN @lt_ekpo
          WHERE werks = @lt_ekpo-werks.


*Sort the tables with proper key
      SORT: lt_ekko  BY ebeln,
            lt_ekpo  BY ebeln ebelp,
            lt_makt  BY matnr,
            lt_t001w BY werks.

*Populate the final table based on the data from EKKO,EKPO,MAKT and T001W using "Parallel Cursor"
      DATA(lt_final) = VALUE ty_t_final( FOR ls_ekpo IN lt_ekpo
                       FOR ls_ekko IN lt_ekko FROM line_index( lt_ekko[ ebeln = ls_ekpo-ebeln ] )
                       WHERE ( ebeln = ls_ekpo-ebeln )
                       FOR ls_makt IN lt_makt FROM line_index( lt_makt[ matnr = ls_ekpo-matnr ] )
                       WHERE ( matnr = ls_ekpo-matnr )
                       FOR ls_t001w IN lt_t001w FROM line_index( lt_t001w[ werks = ls_ekpo-werks ] )
                       WHERE ( werks = ls_ekpo-werks )
                       LET ls_final = VALUE ty_final(
                            lifnr = ls_ekko-lifnr
                            maktx = ls_makt-maktx
                            name1 = ls_t001w-name1 )
                       IN ( CORRESPONDING #( BASE ( ls_final ) ls_ekpo ) ) ).<br>
Read only

2,287

marcobeier Thank you

srikanth.srikanth12 You're correct, the loops are nested so if one of the internal tables is empty, the final result is empty. Of course, you can define conditions inside the constructor expression, but that will make the expression completely unmaintainable. And as I already said, you are just writing "bad" code here, don't use table iterations for implementing "parallel cursor".

Read only

0 Likes
2,287

Thank you all.

thank you so much for suggestion . your comments are really help full .

is there any possibilty of share best example for parallel cursor with new 7.4 or 7.5 features .


Thank you so much again.

SrikanthSuvarna.

Read only

0 Likes
2,287

You ask:

is there any possibility of share best example for parallel cursor with new 7.4 or 7.5 features .

No, it's bad practice, but maybe you didn't understand my first answer, so sorry to repeat myself: it seems that you tried to implement so-called "parallel cursor" using nested table iterations, but that's slower than doing it with classic ABAP because you cannot exit the loops at "key breaks". This is exactly this kind of situation where so-called "new ABAP" should not be used.

Another example where "new ABAP" should not be used, is to update existing variables. Constructor expressions are for constructing, not updating (of course, you could re-construct by duplicating and altering the original value, but you understand that it's slower and so should not be used, especially for huge internal tables).

I hope you understand what I mean.

NB: Please use the COMMENT button for comments, questions, adding details, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.