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

delete a line

Former Member
0 Likes
651

Hi,

how can I delete a line if le_orgeh is not

existing in lt_it_li.

LOOP AT lt_it_li INTO w_int_li.
 
CALL FUNCTION 'Z_EXPORT_PERS' 
  EXPORTING
    im_pernr       = w_int_li-IPPERS
    im_datum       = w_int_li-EVDAT
 IMPORTING
   EX_NOYRS       = le_noyrs
   EX_ENTRY       = le_entry
   EX_ORGEH       = le_orgeh
   EX_SUBRC       = le_subrc.
 
  IF sy-subrc EQ 1.
    MESSAGE e001(zehs_fh_kb).
  ELSEIF sy-subrc EQ 2.
    MESSAGE e002(zehs_fh_kb).
  ELSEIF sy-subrc EQ 9.
    MESSAGE e003(zehs_fh_kb).
  ENDIF.
 
IF THE RETRIEVED le_orgeh is 
AVAILABLE IN  lt_it_li
keep it remaining ELSE delete this row
IN  lt_it_li
 
ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Vijay
Active Contributor
0 Likes
629

hi

try the code in bold...

LOOP AT lt_it_li INTO w_int_li.

if v_index is not initial.

delete from lt_it_li index v_index.

endif.

clear v_index.

CALL FUNCTION 'Z_EXPORT_PERS'

EXPORTING

im_pernr = w_int_li-IPPERS

im_datum = w_int_li-EVDAT

IMPORTING

EX_NOYRS = le_noyrs

EX_ENTRY = le_entry

EX_ORGEH = le_orgeh

EX_SUBRC = le_subrc.

IF sy-subrc EQ 1.

MESSAGE e001(zehs_fh_kb).

ELSEIF sy-subrc EQ 2.

MESSAGE e002(zehs_fh_kb).

ELSEIF sy-subrc EQ 9.

MESSAGE e003(zehs_fh_kb).

ENDIF.

IF THE RETRIEVED le_orgeh is

AVAILABLE IN lt_it_li

keep it remaining

ELSE

v_index = sy-tabix.

endif.

ENDLOOP.

reward points if helpful

regards

vijay

5 REPLIES 5
Read only

Former Member
0 Likes
629

v_lt_it_li[] = lt_it_li[].

LOOP AT lt_it_li INTO w_int_li.

v_tabix = sy-tabix.

CALL FUNCTION 'Z_EXPORT_PERS'

EXPORTING

im_pernr = w_int_li-IPPERS

im_datum = w_int_li-EVDAT

IMPORTING

EX_NOYRS = le_noyrs

EX_ENTRY = le_entry

EX_ORGEH = le_orgeh

EX_SUBRC = le_subrc.

IF sy-subrc EQ 1.

MESSAGE e001(zehs_fh_kb).

ELSEIF sy-subrc EQ 2.

MESSAGE e002(zehs_fh_kb).

ELSEIF sy-subrc EQ 9.

MESSAGE e003(zehs_fh_kb).

ENDIF.

read table v_lt_it_li with key orgeh = le_orgeh.

if sy-subrc <> 0.

delete lt_it_li index v_tabix.

endif.

ENDLOOP.

Read only

Former Member
0 Likes
629

hi,

if u want to compare le_orgeh with the current line of lt_it_li, then use w_int_li-<field>.

if not read the internal table lt_it_li with the value of le_orgeh.

regards,

madhu

Read only

Former Member
0 Likes
629

hi,

do this way ...


loop at  le_orgeh.
 lv_sy-tabix = sy-tabix.
read table lt_it_li with key fld1 =  lt_it_li-fld1.
if sy-subrc = 0.
else.
  delete le_orgeh index lv_tabix.   
endif.
endloop.

Regards,

Santosh

Read only

Vijay
Active Contributor
0 Likes
630

hi

try the code in bold...

LOOP AT lt_it_li INTO w_int_li.

if v_index is not initial.

delete from lt_it_li index v_index.

endif.

clear v_index.

CALL FUNCTION 'Z_EXPORT_PERS'

EXPORTING

im_pernr = w_int_li-IPPERS

im_datum = w_int_li-EVDAT

IMPORTING

EX_NOYRS = le_noyrs

EX_ENTRY = le_entry

EX_ORGEH = le_orgeh

EX_SUBRC = le_subrc.

IF sy-subrc EQ 1.

MESSAGE e001(zehs_fh_kb).

ELSEIF sy-subrc EQ 2.

MESSAGE e002(zehs_fh_kb).

ELSEIF sy-subrc EQ 9.

MESSAGE e003(zehs_fh_kb).

ENDIF.

IF THE RETRIEVED le_orgeh is

AVAILABLE IN lt_it_li

keep it remaining

ELSE

v_index = sy-tabix.

endif.

ENDLOOP.

reward points if helpful

regards

vijay

Read only

Former Member
0 Likes
629

Hi

U should give us more details because we need to know the structure of internal table, anyway it could be like this:

LOOP AT LT_IT_LI INTO W_INT_LI.

  CALL FUNCTION 'Z_EXPORT_PERS'
       EXPORTING
            IM_PERNR = W_INT_LI-IPPERS
            IM_DATUM = W_INT_LI-EVDAT
       IMPORTING
            EX_NOYRS = LE_NOYRS
            EX_ENTRY = LE_ENTRY
            EX_ORGEH = LE_ORGEH
            EX_SUBRC = LE_SUBRC.

  IF SY-SUBRC EQ 1.
    MESSAGE E001(ZEHS_FH_KB).
  ELSEIF SY-SUBRC EQ 2.
    MESSAGE E002(ZEHS_FH_KB).
  ELSEIF SY-SUBRC EQ 9.
    MESSAGE E003(ZEHS_FH_KB).
  ENDIF.
  
  IF LE_ORGEH <> W_INT_LI-ORGEH.
    DELETE LT_IT_LI.
  ENDIF.
ENDLOOP.

but i don't know if it's ok for you because I don't know how the table LT_IT_LI is.

Max