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

Internal Table

Former Member
0 Likes
403

Hi All,

I have an Internal Table

DATA: BEGIN OF IT_RIR OCCURS 0,

MBLNR LIKE MSEG-MBLNR,

BWART LIKE MSEG-BWART,

ERFMG LIKE MSEG-ERFMG,

BUDAT LIKE MKPF-BUDAT,

END OF IT_RIR.

As well a selection option

SELECT-OPTIONS : S_BUDAT FOR MKPF-BUDAT.

I want to compare IT_RIR-BUDAT with S_BUDAT and if true then do further processing.

How this comparision can be done?

Thanks,

Pratibha.

4 REPLIES 4
Read only

Former Member
0 Likes
375

Hi Pratibha,

Use the following Code.

Sort IT_RIR by BUDAT.

Read IT_RIR into wa_rir with key BUDAT = S_BUDAT-low binary search.

if sy-subrc eq 0.

  • Successful do further processing

endif.

Hope this helps.

Please mark helpful answer.

Regards,

Amit Mishra

Message was edited by: Amit Mishra

Read only

Former Member
0 Likes
375

Hai

DATA: BEGIN OF IT_RIR OCCURS 0,

MBLNR LIKE MSEG-MBLNR,

BWART LIKE MSEG-BWART,

ERFMG LIKE MSEG-ERFMG,

BUDAT LIKE MKPF-BUDAT,

END OF IT_RIR.

SELECT-OPTIONS : S_BUDAT FOR MKPF-BUDAT.

at selection-screen on s_budat.

select single budat from mkpf into v_budat.

if sy-subrc <> 0.

raise an Error.

endif.

start-of-selection.

select

MBLNR

BWART

ERFMG

BUDAT

into table it_rir

from mseg inner join mkpf

on mseg-mblnr = mkpf-mblnr

where mkpf-budat in s_budat.

Thanks & regards

Sreenivas

Read only

Former Member
0 Likes
375

you can use,

loop at it_rir.

if NOT it_rir-budat in s_budat.

<stop further processing>.

endif.

endloop.

Read only

Former Member
0 Likes
375

If you want to delete all the records from IT_RIR with comparing BUDAT With the select option S_BUDAT,

DELETE IT_RIR WHERE BUDAT NOT IN S_BUDAT.

This statement will delete all the records of IT_RIR by comparing budat with S_BUDAT.

for each IT_RIR-BUDAT, if a record does not exists in s_budat , it will delete that record.

its a single statement, no need to put it in any loop.

in single shot does the work.

regards

srikanth