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

Code correction reg. subroutine in sapscript

Former Member
0 Likes
658

I wrote a subroutine for my modified sapscript program. In that subroutine, I am retrieving price values (vbap-kzwi5) and passing it to the output table like this:

DATA: zvbeln LIKE vbak-vbeln,

zposnr LIKE vbap-posnr,

zkwmeng LIKE vbdpa-kwmeng,

kzvalue LIKE vbap-kzwi5.

FORM get_kz TABLES input_par STRUCTURE itcsy

output_par STRUCTURE itcsy.

READ TABLE input_par WITH KEY name = 'VBDKA-VBELN' .

MOVE input_par-value TO zvbeln.

READ TABLE input_table WITH KEY name = 'VBDPA-POSNR'

MOVE input_par-value TO zposnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "

EXPORTING

input = zvbeln

IMPORTING

output = zvbeln.

SELECT SINGLE kzwi5 kwmeng FROM vbap

INTO (kzvalue, zkwmeng) WHERE vbeln = zvbeln

AND posnr = zposnr.

MOVE: 'KZ' TO output_par-name.

MOVE: kzvalue TO output_par-value.

APPEND output_table .

CLEAR output_table.

ENDFORM.

Now my question is - Tthe output_par-value is still not getting the value of kzvalue when I debugged the program even after 'Move' statement. Can you please look at it and tell me the necessary code correction?

Thanks a lot.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
603

how is this moving to out put_table.

MOVE: kzvalue TO output_par-value.

APPEND output_table

MOVE: kzvalue TO output_par-value.

append output_par. "chk this table ..

then append output_par to output_table ..

is this the one missing .

5 REPLIES 5
Read only

Former Member
0 Likes
604

how is this moving to out put_table.

MOVE: kzvalue TO output_par-value.

APPEND output_table

MOVE: kzvalue TO output_par-value.

append output_par. "chk this table ..

then append output_par to output_table ..

is this the one missing .

Read only

Former Member
0 Likes
603

Hi,

Check the changes..Marked in bold..

FORM get_kz TABLES input_par STRUCTURE itcsy

output_par STRUCTURE itcsy.

READ TABLE input_par WITH KEY name = 'VBDKA-VBELN' .

MOVE input_par-value TO zvbeln.

READ TABLE <b>input_par</b> WITH KEY name = 'VBDPA-POSNR'

MOVE input_par-value TO zposnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "

EXPORTING

input = zvbeln

IMPORTING

output = zvbeln.

<b>READ TABLE output_par index 1.

check sy-subrc = 0.</b>

SELECT SINGLE kzwi5 kwmeng FROM vbap

INTO (kzvalue, zkwmeng) WHERE vbeln = zvbeln

AND posnr = zposnr.

<b>*MOVE: 'KZ' TO output_par-name. "commented this line</b>

MOVE: kzvalue TO output_par-value.

<b>MODIFY output_par INDEX 1.</b>

<b>*CLEAR output_table. " commented this line</b>

ENDFORM.

Sapscript.

-


This is how you should be calling the subroutine in your sapscript.

/: DEFINE &V_VALUE& := ' '

/: PERFORM get_kz IN PROGRAM ZREPORT

/: USING &VBDKA-VBELN&

/: USING &VBDPA-POSNR&

/: CHANGING &V_VALUE&

/: ENDPERFORM

P1 The sub total value us &V_VALUE&

Thanks,

Naren

Read only

Former Member
0 Likes
603

The code shud be of the form.

READ TABLE output_par WITH KEY name = 'VBDKA-VBELN' .

MOVE: 'KZ' TO output_par-name.

READ TABLE output_par WITH KEY name = 'VBDPA-POSNR'

MOVE: kzvalue TO output_par-value.

append output_par.

clear output_par.

Rewards if helpful.

Viky

Read only

Former Member
0 Likes
603

Hi Krishen,

Can you do following changes and check if the kzvalue is getting populated with some value after the 'select' from vbap table.

FORM get_kz TABLES input_par STRUCTURE itcsy

output_par STRUCTURE itcsy.

DATA: zvbeln LIKE vbak-vbeln,

zposnr LIKE vbap-posnr,

zkwmeng LIKE vbdpa-kwmeng,

kzvalue LIKE vbap-kzwi5.

READ TABLE input_par WITH KEY name = 'VBELN' .

check sy-subrc = 0.

MOVE input_par-value TO zvbeln.

READ TABLE input_table WITH KEY name = 'POSNR'

check sy-subrc = 0.

MOVE input_par-value TO zposnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "

EXPORTING

input = zvbeln

IMPORTING

output = zvbeln.

SELECT SINGLE kzwi5 kwmeng FROM vbap

INTO (kzvalue, zkwmeng) WHERE vbeln = zvbeln

AND posnr = zposnr.

if sy-subrc = 0.

read table output_par with key name = 'KZ'.

check sy-subrc = 0.

output_par-value = kzvalue.

endif.

modify output_par transporting value

where name = 'KZ'.

*Comment out below code

*MOVE: 'KZ' TO output_par-name.

*MOVE: kzvalue TO output_par-value.

*APPEND output_table .

*CLEAR output_table.

ENDFORM.

===================================

Also change your piece of code in sapscript as follows:

/: PERFORM get_kz in program zpgmname

/: using &VBELN&

/: using &POSNR$

/: changing &KZ&

Hope this will give you an idea.

Cheers,

Vikram

Please reward for helpful replies!!

Read only

Former Member
0 Likes
603

Hi,

Please reward points for helpful answers and close the thread if the problem is solved..

Thanks,

Naren