cancel
Showing results for 
Search instead for 
Did you mean: 

Sapscript printing only the last value

Former Member
0 Kudos

Hello,

Im currently coding subroutine for medruck.. My problem is sapscript is only printing the last value of the item for all items.. For example:

Item # 1 10 pcs 10,000.00

Item # 2 5 pcs 10,000.00

Item # 3 5 Pad 10,000.00

where actually the value of item 1 and item 2 is not 10,000.. sapscript prints only the price of item # 3 for the first two items.. here is my code..

TABLES: konv, ekko, ekpo.

DATA: BEGIN OF tab OCCURS 0,

brtwr LIKE ekpo-brtwr,

ebelp LIKE konv-kposn,

ebeln LIKE ekko-ebeln,

knumv LIKE ekko-knumv,

kbetr LIKE konv-kwert,

END OF tab.

DATA: sum TYPE p DECIMALS 2, gross TYPE p DECIMALS 2, val(16) TYPE c, d_knumv LIKE ekko-knumv, tab1 LIKE tab, val1(20) TYPE c,

ext TYPE p DECIMALS 2, val2(20) TYPE c, extend TYPE p DECIMALS 2.

REFRESH: tab.

READ TABLE in_tab INDEX 1.

CHECK sy-subrc = 0.

SELECT brtwr ebelp ebeln FROM ekpo INTO TABLE tab WHERE ebeln = in_tab-value.

LOOP AT tab.

AT NEW ebelp.

tab-kbetr = 0.

ext = 0.

ENDAT.

SELECT SINGLE knumv FROM ekko INTO tab-knumv WHERE ebeln = tab-ebeln.

SELECT SINGLE kbetr FROM konv INTO tab-kbetr WHERE knumv = tab-knumv AND kposn = tab-ebelp AND kschl = 'ZDEL'.

ext = tab-brtwr + tab-kbetr.

AT END OF ebelp.

READ TABLE out_tab INDEX 1.

WRITE ext TO val.

out_tab-value = val.

MODIFY out_tab INDEX 1.

ENDAT.

CLEAR: tab.

ENDLOOP.

i used this code using abap only and it work. there seems to be a problem in sapscript.. Thank u for the help guys..

Thanks,

JP

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

can i do that in medruck?.. were using medruck im just using sub routines for it..

Former Member
0 Kudos

try to place the perform in proper place.....

check where the &itab-item& &itab-unit& are placed (that is correct element where they are placed) and there place the

&itab-price&....

otherwise debug and see where the item details are getting populated and what is going wrong..

utilities --->activate debugger...

Former Member
0 Kudos

put ur write_form with in loop...

loop at itab.

write_form..

element = 'ddd'

endloop.

in script check ...

check wheather element is specified there r not

/e ddd.

&itab- & &itab- &