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

SAP Script

Former Member
0 Likes
435

hi friends,

iam copying form F140_INT_DOCU_01 INTO ZF140_INT_DOCU_1. The print program is RFKORD30. my requiredment is i dont want to modify the print program.

but i want to calculate some totals based on debit and credit and display it in form. so i writing subroutine for this. but when callig this in text editor it is not selecting data from table and displaying it. pls help me how to code.

babu

3 REPLIES 3
Read only

Former Member
0 Likes
375

Hello Chandra,

U can use this code.

PERFORM GET_VEND_NAME_MOD IN PROGRAM /RB17/YV_FORMS_PUTAWAY_LIST

USING &LTAK-VBELN&

USING &LTAP-POSNR&

USING &LTAK-LGNUM&

USING &LTAK-BWART&

USING &LTAK-BWLVS&

USING &LTAK-MBLNR&

USING &LTAK-MJAHR&

CHANGING &VEND_NAME&

CHANGING &TRAID&

CHANGING &SHIPPING_UNIT&

CHANGING &VEKP_VKORG&

CHANGING &VEKP_VTWEG&

FORM get_vend_name_mod TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy .

DATA : z_vbeln LIKE ltak-vbeln,

z_lgnum LIKE ltak-lgnum,

z_bwart LIKE ltak-bwart,

z_bwlvs LIKE ltak-bwlvs,

z_mblnr LIKE ltak-mblnr,

z_mjahr LIKE ltak-mjahr,

z_posnr LIKE ltap-posnr,

l_f_handle LIKE vevw-handle,

l_f_werks LIKE mseg-werks,

l_f_objkey(14) TYPE c,

l_f_stock1(35) TYPE c.

CONSTANTS : l_f_stock(35) TYPE c VALUE 'Stock Transfer from Plant 9060'.

CLEAR : likp,lfa1.

  • Get the delivery number

READ TABLE in_tab WITH KEY name = 'LTAK-VBELN'.

CHECK sy-subrc = 0.

z_vbeln = in_tab-value.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = z_vbeln

IMPORTING

output = z_vbeln.

  • position number

READ TABLE in_tab WITH KEY name = 'LTAP-POSNR'.

CHECK sy-subrc = 0.

z_posnr = in_tab-value.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = z_posnr

IMPORTING

output = z_posnr.

  • Warehouse number

READ TABLE in_tab WITH KEY name = 'LTAK-LGNUM'.

IF sy-subrc = 0.

z_lgnum = in_tab-value.

ENDIF.

  • Movement type

READ TABLE in_tab WITH KEY name = 'LTAK-BWART'.

IF sy-subrc = 0.

z_bwart = in_tab-value.

ENDIF.

READ TABLE in_tab WITH KEY name = 'LTAK-BWLVS'.

IF sy-subrc = 0.

z_bwlvs = in_tab-value.

ENDIF.

  • Material document number and year

READ TABLE in_tab WITH KEY name = 'LTAK-MBLNR'.

IF sy-subrc = 0.

z_mblnr = in_tab-value.

ENDIF.

READ TABLE in_tab WITH KEY name = 'LTAK-MJAHR'.

IF sy-subrc = 0.

z_mjahr = in_tab-value.

ENDIF.

CONCATENATE z_mblnr z_mjahr INTO l_f_objkey.

IF ( z_lgnum = 'A11' AND z_bwart = '301' AND z_bwlvs = '302' ).

SELECT SINGLE handle INTO l_f_handle FROM vevw

WHERE object = 'MM' AND

objkey = l_f_objkey.

IF sy-subrc EQ 0 AND

NOT l_f_handle IS INITIAL.

SELECT SINGLE * FROM vekp

WHERE handle = l_f_handle.

g_f_exidv = vekp-exidv.

ENDIF.

SELECT SINGLE werks INTO l_f_werks FROM mseg

WHERE

mblnr = z_mblnr AND

mjahr = z_mjahr AND

shkzg = 'H'.

IF sy-subrc EQ 0

AND l_f_werks EQ '9060'.

l_f_stock1 = l_f_stock.

ENDIF.

SELECT SINGLE * FROM likp

WHERE vbeln = z_vbeln .

IF sy-subrc EQ 0 .

SELECT SINGLE * FROM lfa1

WHERE lifnr = likp-lifnr.

ENDIF.

ELSE.

SELECT SINGLE * FROM likp

WHERE vbeln = z_vbeln .

IF sy-subrc EQ 0 .

SELECT SINGLE * FROM lfa1

WHERE lifnr = likp-lifnr.

l_f_stock1 = lfa1-name1.

ENDIF.

SELECT SINGLE vbeln FROM vbfa

INTO vbfa-vbeln

WHERE vbtyp_n = 'X'

AND vbelv = z_vbeln.

SELECT SINGLE * FROM vepo

WHERE venum = vbfa-vbeln.

IF sy-subrc EQ 0 .

SELECT SINGLE * FROM vekp

WHERE venum = vepo-venum.

ENDIF.

IF vekp-exidv IS INITIAL.

SELECT SINGLE * FROM vekp

WHERE vpobj IN ('01','03')

AND vpobjkey = z_vbeln.

g_f_exidv = vekp-exidv.

ENDIF.

ENDIF.

READ TABLE out_tab WITH KEY name = 'VEND_NAME'.

CHECK sy-subrc = 0.

out_tab-value = l_f_stock1.

SHIFT out_tab-value LEFT DELETING LEADING space.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab WITH KEY name = 'TRAID'.

CHECK sy-subrc = 0.

out_tab-value = likp-traid.

SHIFT out_tab-value LEFT DELETING LEADING space.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab WITH KEY name = 'SHIPPING_UNIT'.

CHECK sy-subrc = 0.

out_tab-value = g_f_exidv.

SHIFT out_tab-value LEFT DELETING LEADING space.

SHIFT out_tab-value LEFT DELETING LEADING '0'.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab WITH KEY name = 'VEKP_VKORG'.

CHECK sy-subrc = 0.

out_tab-value = vekp-vkorg.

MODIFY out_tab INDEX sy-tabix.

READ TABLE out_tab WITH KEY name = 'VEKP_VTWEG'.

CHECK sy-subrc = 0.

out_tab-value = vekp-vtweg.

MODIFY out_tab INDEX sy-tabix.

*} INSERT

ENDFORM. "get_vend_name_mod

If useful reward.

Vasanth

Read only

Former Member
0 Likes
375

HI Chandra,

If you are not modifying your print program then where you are writing your subroutine.Put the break point at the place where you wrote the code for the subroutine and activate debugger in the Sapscript form and check where you are doing wrong.

Read only

Former Member
0 Likes
375

Hi,

You need to write the External Subroutine in the form itself, and you need to write the Form and endform in a Z program .

<b>

example</b>:

in sapscript code (page windows):

perform zperform in program zprogram 
using &field1& 
changing &field2& 
endperform

make a report with name: zprogram,

which contains the form: zperform

report zprogram. 

tables: itcsy. 

data: var01(10) type c. 


form zperform tables tabin structure itcsy 
tabout structure itcsy. 


read table tabin with 
key name = 'field1'. 
var01 = tabin-value. 

var01 = var01 + 1. 


tabout-name = 'field2'. 
tabout-value = var01. 
append tabout. 

endform.

See the below link for more info ..

http://sap.niraj.tripod.com/id18.html

Thanks

Sudheer