cancel
Showing results for 
Search instead for 
Did you mean: 

help in the abap code

Former Member
0 Kudos

select distinct jhagainserent jhagaregulierer jhaga~avm_nr

jhagaref_vbeln jhakknumv into

corresponding fields of table bodyitab

from jhaga inner join jhak on jhaga~avm_nr =

jhakavm_nr where jhagainserent = p_advnum and

jhaga~fakdatum in r_datum.

write: 'the query is working'.

select knumv kschl kbetr kwert

from konv

into table cdata

for all entries in bodyitab

where konv~knumv = bodyitab-knumv.

I am getting the error in this line.....

loop at cdata into wac where knumv = bodyitab-knumv.

It is not comparing the condition out here.

Thanks in advance.

Santhosh

Accepted Solutions (0)

Answers (1)

Answers (1)

Vinod_Chandran
Active Contributor
0 Kudos

Hi Santosh,

Before the statement "loop at cdata into wac where knumv = bodyitab-knumv." are you selecting value from bodyitab using read or loop?

Thanks

Vinod

Former Member
0 Kudos

Hi Vinod,

I got stuck in the query here

types: begin of bodydata,

inserent type jhaga-inserent,

REGULIERER type jhaga-REGULIERER,

vavartyp type jhaga-vavartyp,

REF_VBELN type jhaga-REF_VBELN,

ber_termin type jhaga-ber_termin,

AVM_NR type jhaga-AVM_NR,

KNUMV type jhak-KNUMV,

end of bodydata.

data:bodyitab type standard table of bodydata with header line,

wab type bodydata,

zzdate(8) type c,

zzdate1(5) type c.

select distinct jhagainserent(agency number) jhagaregulierer (advertiser number)

jhagavavartyp(day) jhagaavm_nr jhaga~ref_vbeln

jhagaber_termin(billin date) jhakknumv into

corresponding fields of table bodyitab

from jhaga inner join jhak on jhaga~avm_nr =

jhakavm_nr where jhagainserent = p_advnum and

jhaga~fakdatum in r_datum.

select knumv kschl kbetr kwert

from konv into table cdata

for all entries in bodyitab

where konv~knumv = bodyitab-knumv.

<b>loop</b> at bodyitab into wab.

write:wab-ber_termin to zzdate.

concatenate zzdate0(2) zzdate2(2) into zzdate1

separated by '/'.

<b>loop</b> at cdata into wac where knumv = wab-knumv.

case wac-kschl.

when 'ZRAT'.

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.

....... check for various condition types

when 'ZSED'

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.

if sy-subrc = 0.

  • append accitab.

append w_accitab to accitab.

append cdata.

clear w_accitab.

endloop.

endloop.

What I am trying to achieve?

I have to read the data from the queries into the body of the form i.e the description,date, sales order number,invoice number and the rates,subtotals and amounts.

I have to get the data from two set of tables one from the j* series of tables and the rates from 'KONV' table in a comon internal table FOR THAT the only common field is 'knumv' between konv and jhak.

Also each sales order number(avm_nr) is related to unique billing document numbers(ref_vbeln) that inturn are linked to a common condition type number (knumv)

when I ran the query - without 'vavartyp' and 'ber_termin'

I do get unique records in 'bodyitab' but I have to read the data from this itab to run the next query and compare the condition type record in 'cdata'

that where I used

'loop at cdata into wac where knumv = bodyitab-knumv' otherwise I cannot get pass through the case statement.

Hence i changed it to

'loop at cdata into wac where knumv = wab-knumv'

created a work area for this query and went ahead to read the other fields 'vavartyp' and 'ber_termin' then I do not get the unique records.

MY OBJECTIVE IS TO READ UNIQUE RECORDS. EVERY 'REF_VBELN' HAS A UNIQUE RECORD ATTACHED TO 'KNUMV' i AM READING THE RECORDS MULTIPLE TIMES INTO THE FORM.

I NEED HELP HERE. I AM TRYING A LOT WAYS TO LINK THESE FIELDS BUT NO WAY.

IS THERE ANY WAY YOU CAN HELP ME?

THANKS

santhosh

Vinod_Chandran
Active Contributor
0 Kudos

Hi Santhosh,

I understand that you have problem with the statement

loop at cdata into wac where knumv = wab-knumv.

Hope the values for KNUMV in CDATA and BODYITAB are same.

Can you check whether there is any problem with leading zeors.

Also check the reference type (data element) for jhak-KNUMV and bodydata-knumv are same.

Thanks

Vinod

Former Member
0 Kudos

Thanks,

I checked the data element of KNUMV for both the 'JHAK' sand 'konv' tables are same. while bodydata-knumv is defined by jhak-knumv field type.

No problem of leading zeros because the data i am checking for starts from 1000....567 something like that.

The values in both the itabs are same too.

let me give you an example and explain..

consider this order number

avm_nr -100001421 has three billing document numbers

(because billed on three separate days)

1000010370 (first day of billing)-

1000010374( second day)

1000010383 (third day)

The corresponding amount for each day is

1000010370 -


1524 (konv-kwert field)

1000010374 -


1143 ( konv-kwert field)

1000010383 -


1099 (konv-kwert field)

al the three carry the same condition number

knumv- 10000010305

The requirement is that I have to show the subtotals for each of the amounts, therefore I have to check for the various pricing types in konv and display the subtotal in the form (hence Ihave used the case ... endcase and check for various pricing types)

Now in bodyitab I have records for this order has

avm_nr ref_vbeln knumv

100001421 1000010370 10000010305

100001421 1000010374 10000010305

100001421 1000010383 10000010305

in cdata internal table

knumv kschl kwert kbetr

10000010305 zrat 1524.00

10000010305 zrtc 1524.00 127

.

.

.

10000010305 zbet 1143.00

10000010305 zrat 1143.00

10000010305 zrtc 1143.00 96

.

.

.

10000010305 zbet 1143.00

10000010305 zrat 1099.00

10000010305 zrtc 1099.00 127

.

.

.

10000010305 zbet 1099.00

you have the records like this... in the same internal table

when i compare for every document number it runs through all the set of records and displays

the 1054, 1143, 1099 for each of them but in reality

1054 is only for 100.. 370, 1143 for 100... 374, 1099 for 100.. 383 instead of one record for each it displays all the three records for each.

i know because i am comparing with knumv it runs through all the records and displays each time but there is no other field like 'ref_vbeln' whichis unique available in konv table or any field in unique field in konv that I can link to j* series of table.

I am positive that i cannot take away the case.... endcase statement because there are about 100 condition types that i need check because the requirement is that the subtotals has to be displayed in the form.

This is what i am encountering I would appreciate if you could come up with any other way approaching it.

Thanks

Santhosh

Vinod_Chandran
Active Contributor
0 Kudos

Hi Santhosh,

I understood your requirement. But unfortunatly I do not have access to the system at the moment. But can you check the KONV table for some kind of reference field?

Is the item number in KONV helpful?

Also I have doubt. How come you can have the same condition number (KNUMV) for different billing documents? Please check you select statement.

select distinct jhagainserent jhagaregulierer jhaga~avm_nr

jhagaref_vbeln jhakknumv into

corresponding fields of table bodyitab

from jhaga inner join jhak on jhaga~avm_nr =

jhakavm_nr where jhagainserent = p_advnum and

jhaga~fakdatum in r_datum.

You are selecting the KNUMV from the header table JHAK. In the inner join your condition is based on AVM_NR and this is the sales order number. I think instead of selecting the condition number for the billing document you are selecting condition number of the sales order.

Thanks

Vinod