Skip to Content
4
May 27, 2020 at 11:16 PM

Add a CHECK or CONTINUE in a FOR Loop Expression

841 Views Last edit May 27, 2020 at 11:20 PM 4 rev

TRY.
    et_agents = VALUE #( BASE et_agents
                         FOR ls_agent IN it_agents
                 LET check = NEW zcl_te_pos_deleg( CONV #( ls_agent-objid )
                              )->is_within_limit( CONV #( iv_amount ) )
                 IN
                  ( COND #( WHEN check = abap_true
                            THEN CORRESPONDING #( ls_agent )
                            ELSE THROW RESUMABLE zcx_swf_no_agent_found( )
                          )
                  )
                      ).
CATCH BEFORE UNWIND zcx_swf_no_agent_found.
  RESUME.
ENDTRY.

DELETE et_agents WHERE table_line IS INITIAL."<- I want to avoid doing this

The issue is that after an exception is raised and it RESUMEs, an empty row is appended in table ET_AGENTS before processing the next iteraion of IT_AGENTS.

Is there a way in the FOR LOOP Expressions which works like a CHECK or CONTINUE statement like it works in the traditional LOOP/ENDLOOP statement?

Thanks,

Sougata.