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

how to avoid hard coding

Former Member
0 Likes
1,778

Hello experts,

I am retrieving the data from bseg, bkpf and bsad tables into 3 different internal tables.. like.. first of i took the data from bseg table (BELNR, BUKRS, GJAHR, CPUDT, CPUTM) into one internal table ITAB1.

for all entries in ITAB1, I selected the data from BSEG table (BELNR, GJAHR, BUKRS, DMBTR, SHKZG, KUNNR, UMSKS, UMSKZ, AUGDT, AUGBL, GUONR, BUZEI) into another internal table ITAB2.

based on itab2 key fields i retrieved the data from BSAD table (XBLNR, REBZG, PRCTR, VBELZ, ZUONR, KUNNR, XREF1, XREF2, XREF3) into itab3.

Now my problem is ... I have to filter the data based on the fields of BSAD.

Eg: BSAD-XREF3 <> 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379 or 325 delete the records......... from itab3.

My requirement is to avoid this hard coding how to do it... where to specify all those values and how to pass that variable in the select statement... please can anyone guide me

its very urgent

SRI

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
989

ranges : rxref3 for bsad-xref3.

rxref3-low = '170'.

rxref3-high = '179'.

rxref3-sign = 'E'.

rxref3-option = 'BT'.

append rxref3.

rxref3-low = '370'.

rxref3-high = '379'.

rxref3-sign = 'E'.

rxref3-option = 'BT'.

append rxref3.

rxref3-low = '270'.

rxref3-high = '279'.

rxref3-sign = 'E'.

rxref3-option = 'BT'.

append rxref3.

rxref3-low = '325'.

rxref3-sign = 'E'.

rxref3-option = 'EQ'.

append rxref3.

now use select * from bsad .......where xref3 in rxref3.

regards

shiba dutta

6 REPLIES 6
Read only

Former Member
0 Likes
990

ranges : rxref3 for bsad-xref3.

rxref3-low = '170'.

rxref3-high = '179'.

rxref3-sign = 'E'.

rxref3-option = 'BT'.

append rxref3.

rxref3-low = '370'.

rxref3-high = '379'.

rxref3-sign = 'E'.

rxref3-option = 'BT'.

append rxref3.

rxref3-low = '270'.

rxref3-high = '279'.

rxref3-sign = 'E'.

rxref3-option = 'BT'.

append rxref3.

rxref3-low = '325'.

rxref3-sign = 'E'.

rxref3-option = 'EQ'.

append rxref3.

now use select * from bsad .......where xref3 in rxref3.

regards

shiba dutta

Read only

0 Likes
989

Shiba,

you are solution makes sense...

so here one more point is also there actually before I filter those records I have to separate those records into debit and credit records into 2 different internal tables and then i have to filter those records ....

so for the debit and credit records for the same fields the set of values are different means

for credit records condition is BSAD-XREF3 = 345 or 369 then delete the records....

for debit records condition is BSAD-XREF3 = 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379 or 325. then delete the records

in this case how to apply the condition and filter the records

I really appreciate your valuable time

SRI

Read only

0 Likes
989

i think you can get the two int tab with icred and idebt before using the for all entries in bsad table.

for credit also declare one range...

ranges rxrefc for bsad-xref3.

rxrefc-low = '345'.

rxrefc-sign = 'E'.

rxrefc-option = 'EQ'.

append xrefc.

rxrefc-low = '369'.

rxrefc-sign = 'E'.

rxrefc-option = 'EQ'.

append xrefc.

now use

select ... from bsad for all entries in icred into table ibsadc where xref3 in rxrefc.

and for debt...

select ... from bsad for all entries in idebt into table ibsadd where xref3 in rxref3.

regards

shiba dutta

Read only

0 Likes
989

Ok shiba,

I will try to implement that tomorrow morning and if i get any problem i will get back to you

Thanks a ton for your quick reply..

SRI

Read only

Former Member
0 Likes
989

hi

if all the hard coded values are a result set of a condition..like order type = 'XX' or something, then you can directly use that condition in the select...if those values are going to be static for your scenario, then probably you can build a range with those values harcoded and then use NOT IN in your select..again, you have to pass those values (hard code!) to build your range

if helpful, reward

Sathish. R

Read only

Former Member
0 Likes
989
if  BSAD-XREF3  ( ge170  and   le 179 )  or  if  BSAD-XREF3  ( ge270  and   le 279 )   or if  BSAD-XREF3  ( ge370  and   le 379 )   or  BSAD-XREF3 eq 325 .

de;ete   from itab.

endif 

reward points if it is uefull .......

Girish