cancel
Showing results for 
Search instead for 
Did you mean: 

Pulling the condition records - help in the ABAP code -urgent!!!!!

Former Member
0 Kudos
525

hi folks,

I need some urgent help here..

I have discussed this portion before in the forum but there are some changes and I need some help here.

The code goes like this....

select knumv kschl kbetr kwert

from konv into table cdata

for all entries in bodyitab21

where konv~knumv = bodyitab21-knumv

and konv~kwert > 0.

        • I am successfully pulling the data into cdata here..

I need to check for various condition types that are around 100. I need to split them into two types because some condition types containe just pricing values while some others have values in % (but the value not stored in that format) To do the extra coding I have use two differetn case statements and that's what i have done here.

<b>My probelm is I will have to check for each condition type, if the 'kwert' field has some value in it pull the data and there is a condition text associcated to it in the table 'T685T' that needs to be pulled into the itab.

This process has to be done for every condition type.</b>Given this scenario how can i do it?

loop at cdata into wac.

case wac-kschl.

when 'ZRAT' OR 'ZAGR' OR 'ZRCR' OR 'Y098' OR 'Y007' OR 'ZREW' OR 'Y106' OR 'ZTSR' OR 'Y127' OR 'Y125' OR 'Y126' OR 'Y124' OR 'Y157' OR 'Y092' OR 'Y085' OR 'Y090' OR 'ZMZD' OR 'Y215' OR 'Y214' OR 'Y111' OR 'ZC$D' OR 'ZAUD' OR 'ZTHX' OR 'ZCOL'

OR 'ZCFE' OR ZSPA' OR 'ZBOX' OR 'ZCOR' OR 'Y130' OR 'ZBOR'

OR 'Y108' OR 'ZFPP' OR 'Y204' OR 'Y200' OR 'Y202' OR 'Y201' OR 'Y203' OR 'Y002' OR 'ZSCR' OR 'Y128' OR 'Y100' OR 'ZABS' OR 'ZSMG' OR 'ZFRE' OR 'ZREC' OR 'ZCOM' OR 'ZPMG' OR 'BEMG' OR 'ZDTI' OR'ZBET'.

<b>***** the first set of these condition types have just values</b> if wac-kbetr = ' ' AND wac-kwert = ' '.

continue.

else.

p = wac-kbetr.

i = p.

c = i.

MOVE c to w_accitab-zrate.

MOVE wac-kbetr to w_accitab-zrate.

MOVE wac-kwert to w_accitab-zsubtotal.

endif.

when 'ZSED' OR 'ZRFQ' OR 'ZIMP' OR 'ZERR'

OR 'ZECD' 'ZAC1' OR 'ZAC%' OR 'ZAC2' OR 'ZSED' OR 'ZRFQ' OR 'ZIMP' OR 'ZERR' OR 'ZECD' 'ZQUD' OR 'ZEMP' OR 'Y101' OR 'Y012' OR 'ZCHU' OR 'Y054' OR 'Y065' OR 'Y066' OR 'Y067' OR 'Y068' OR 'Y069' OR 'Y096'

OR 'Y103' OR 'Y010' OR 'Y070' OR 'Y071' OR

'Y072' OR 'Y073' OR 'Y074' OR 'Y075' OR 'Y076'

OR 'Y077' OR 'Y078' OR 'Y079' OR 'Y156' OR OR 'Y148'

OR 'Y102' OR 'Y205' OR 'Y206' OR 'Y207' OR 'Y208' OR

'Y209' OR 'Y213' OR 'Y210' OR 'Y211' OR 'Y212' OR 'Z%DS'

OR 'Z%DO' OR 'Y113' OR 'Y151' OR 'Y152' OR 'Y153' OR

'Y154' OR 'Y155' OR 'Y147' OR'Z%PB' OR 'Y142' OR 'Y131'

OR 'Y141' OR 'Y149' OR 'ZDEO' OR 'Z%DR' OR 'Y115' OR

'Y116' OR 'Y095' OR 'Y084' OR 'ZSA$' OR 'ZSA%' OR

'ZPA$' OR 'ZPA%'.

          • the second set of these condition types have just values that has to be converted into %.

if wac-kbetr = ' ' AND wac-kwert = ' '.

clear w_accitab-zrate.

continue.

else.

p = wac-kbetr.

p = p / 10.

if p < 1.

rate+0(1) = '-'.

endif.

if i = 0.

clear w_accitab-zrate.

else.

i = p.

c = i.

shift c right deleting trailing '-'.

concatenate rate c '%' into rate.

condense rate no-gaps.

MOVE wac-kbetr to w_accitab-zrate.

MOVE rate to w_accitab-zrate.

clear rate.

MOVE wac-kwert to w_accitab-zsubtotal.

endif.

endif.

Thanks alot in advance.

Santhosh

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Maybe this will help you, otherwise I'm missing something.

[code]

data: begin of wac,

kschl type t685t-kschl,

vtext type t685t-vtext,

end of wac.

case wac-kschl.

when 'ZRAT' or 'ZAGR' or 'ZRCR' or 'Y098' or 'Y007' or 'ZREW' or 'Y106'

or 'ZTSR' or 'Y127' or 'Y125' or 'Y126' or 'Y124' or 'Y157' or 'Y092' or

'Y085' or 'Y090' or 'ZMZD' or 'Y215' or 'Y214' or 'Y111' or 'ZC$D' or

'ZAUD' or 'ZTHX' or 'ZCOL' or 'ZCFE' or 'ZSPA' or 'ZBOX' or 'ZCOR'

or 'Y130' or 'ZBOR' or 'Y108' or 'ZFPP' or 'Y204' or 'Y200' or 'Y202' or

'Y201' or 'Y203' or 'Y002' or 'ZSCR' or 'Y128' or 'Y100' or 'ZABS' or

'ZSMG' or 'ZFRE' or 'ZREC' or 'ZCOM' or 'ZPMG' or 'BEMG' or 'ZDTI'

or'ZBET'.

            • Some code

when 'ZSED' or 'ZRFQ' or 'ZIMP' or 'ZERR'

or 'ZECD' or 'ZAC1' or 'ZAC%' or 'ZAC2' or 'ZSED' or 'ZRFQ' or 'ZIMP' or

'ZERR' or 'ZECD' or 'ZQUD' or 'ZEMP' or 'Y101' or 'Y012' or 'ZCHU' or

'Y054' or 'Y065' or 'Y066' or 'Y067' or 'Y068' or 'Y069' or 'Y096'

or 'Y103' or 'Y010' or 'Y070' or 'Y071' or

'Y072' or 'Y073' or 'Y074' or 'Y075' or 'Y076'

or 'Y077' or 'Y078' or 'Y079' or 'Y156' or 'Y148'

or 'Y102' or 'Y205' or 'Y206' or 'Y207' or 'Y208' or

'Y209' or 'Y213' or 'Y210' or 'Y211' or 'Y212' or 'Z%DS'

or 'Z%DO' or 'Y113' or 'Y151' or 'Y152' or 'Y153' or

'Y154' or 'Y155' or 'Y147' or'Z%PB' or 'Y142' or 'Y131'

or 'Y141' or 'Y149' or 'ZDEO' or 'Z%DR' or 'Y115' or

'Y116' or 'Y095' or 'Y084' or 'ZSA$' or 'ZSA%' or

'ZPA$' or 'ZPA%'.

        • Some code

endcase.

select single vtext into wac-vtext from t685t

where spras = sy-langu

and kschl = wac-kschl.

write:/ wac-kschl, wac-vtext.

[/code]

Regards,

Rich Heilman

Former Member
0 Kudos

hi Rich,

I have this query .....

I am having the problem with this query.

I need to pull only the records that have value in either of the fields 'kbetr' or 'kwert' or both.

select knumv kschl kbetr kwert

from konv into table cdata

for all entries in bodyitab21

where konv~knumv = bodyitab21-knumv

and konvkwert > 0 or konvkbetr > 0.

when I give this query it throwas all the records in the table 'KONV' without comparing the right condition number.

and when I exclude

'and konvkwert > 0 or konvkbetr > 0.' it pulls the records for that condition numbers comapring the right values but the disadvantage is there are a lot empty records that gets stored which i do not want.

How can I modify this query to achieve the results.

Your help is greatly appreciated here.

thanks

Santhosh

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You must be careful with your where clause.



select knumv kschl kbetr kwert
       from konv into table cdata
              for all entries in bodyitab21
                  where konv~knumv = bodyitab21-knumv
                    and ( konv~kwert > 0 
                       or konv~kbetr > 0 ).


You must wrap that condintion in parenthasis.

If these posts have helped you please reward points accordingly. Thanks.

Regards,

Rich Heilman

Answers (0)