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

New Syntax for Loop

0 Likes
1,746

Hi team,

please let me know the new syntax for below code.

LOOP AT IT_BSID ASSIGNING FIELD-SYMBOL(<FS_BSID>).
IF <FS_BSID>-VBELN IS INITIAL.
<FS_BSID>-VBELN = <FS_BSID>-XBLNR.
ENDIF.
ENDLOOP.

5 REPLIES 5
Read only

FredericGirod
Active Contributor
1,631

What did you expect as "New syntax" ?

LOOP AT IT_BSID
     REFENCE INTO DATA(o_bsid_line).
  o_bsid_line->vbeln = COND #( WHEN o_bsid_line->vbeln IS INITIAL
                                 THEN o_bsid_line->xblnr
                                 ELSE o_bsid_line->vbleln ).
ENDLOOP.
Read only

0 Likes
1,631

Hi frdric.girod

am expecting with this new syntax

LT_BSID = VALUE #( FOR WA_BSID IN IT_BSID
* WHERE ( VBELN = WA_BSID-XBLNR ) ).

how to check vbeln is initial

don't want to use loop statement .

Read only

Patrick_vN
Active Contributor
1,631

Or something like this?

*   Return only the data where PROFIT_CENTER has been found
    [new_table] = VALUE #(  FOR data
                            IN [old_table]
                            WHERE ( profit_center IS NOT INITIAL )
                            ( document_date     = data-document_date
*                             ..
                            )
                         ).
Read only

0 Likes
1,631

Hi pvnierop

want results as mentioned below.

Read only

0 Likes
1,631

Easiest would be to use COALESCE in the corresponding SQL statement in that case I think.

But I guess you could try something like this (see this blog for details on COND & SWITCH)

    [table] = VALUE #(  FOR data
                        IN [table]
                        (  vbeln = COND #( WHEN data-vbeln IS INITIAL THEN data-xblnr
                                           ELSE data-vbeln
                                         )
                          )
                     ).