Application Development 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: 

sub-routines in scripts

Former Member
0 Kudos

Hi Everybody,

i have copied the standard script F140_DOCU_EXC_01 into zf140_doc, in that form i need to caluculate Net amount in text element 521 in main window. for that i have written the subroutine.

PERFORM <subroutin_name> IN PROGRAM <prog_name>

USING <parms>

CHANGING <parms>

ENDFORM.

FORM <form_name> TABLES in_var type ITCSY

out_var type ITCSY.

endform.

the above code is not a complete one.i need to caluculate the net amount (&RF140-WRSHB). i am not able to calucualte the net amount, i mean from where should i get the data. and y do u we need the ITCSY stru.. could some one help me with a code.

Thanks

Srikanth

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Please see the code below,

In script

PERFORM GET_CUST_ADDRESS IN PROGRAM ZSHXS011_TESTING

using &vbdkr-adrnr&

changing &strt4&

changing &str5&

ENDPERFORM

In program

*intab contains input parameters

*process the intab values and populate into out_tab

form get_address tables in_tab structure itcsy

out_tab structure itcsy.

Data : addr1_sel like addr1_sel.

read table in_tab index 1. *adrnr value

if sy-subrc eq 0.

move in_tab-value to addr1_sel-addrnumber.

endif.

call function 'ADDR_GET'

exporting

address_selection = addr1_sel

importing

address_value = addr1_val

*assign street 4 to outtab

read table out_tab index 1.

if sy-subrc eq 0.

move addr1_val-str_suppl2 to out_tab-value.

modify out_tab index 1.

endif.

*assign street 5 to outtab

read table out_tab index 2.

if sy-subrc eq 0.

move addr1_val-str_suppl2 to out_tab-value.

modify out_tab index 2.

endif.

after the process we need to populate the values into outab.

Hope this will solve your problem.

Sasi

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Have you looked at the standard program for this form. It should show you how this field is calculated. Also, there is no need to do a subroutine here. Why make it harder on yourself. The RF140-WRSHB field is most likely a global field in the print program.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

Could you please tell me the name of the print program.

Thanks

Srikanth

0 Kudos

Looks like there are a hand full which use this structure in the program.



J_1HKORD                         Print Program: Document Extract                            
RFCASH00                         Cash Journal                                               
RFKORB00                         Internal Documents                                         
RFKORD00                         Print Program: Payment Notice                              
RFKORD10                         Print Program: Account Statement                           
RFKORD11                         Print Program: Customer Statement                          
RFKORD20                         Print Program: Charges for a Bill of Exchange              
RFKORD30                         Print Program: Internal Documents                          
RFKORD40                         Print Program: Individual Letters and Standard Letters     
RFKORD50                         Print Program: Document Extract                            
RFKORD60                         Print Program: Failed Payments                             
RFKORD70                         Print Program: Periodic Settlement                         
RFKORD80                         Print Program: Cash Documents                              
RFKORDC1                         Print Program: Cash Receipts for Czech Republic and Slovaki
RFKORDJ1                         Receipt after Payment (Japan)                              
RFKORDJ2                         Receipt Before Payment (Japan)                             
RFKORDJ3                         Receipt - Cleared (Japan)                                  
RFKORDJ4                         Print Program: Statement of Account (Period. Billing)      
RFKORDP1                         Printout of Official Receipts After Payment (Philippines)  
RFKORDP2                         Printout of Official Receipts Before Payment (Philippines) 
RFKORDP3                         Printout of Customer Statements (Philippines)              
RFKORDR1                         Print Program: Internal Docs for Confederation of Independe
RFKORDR2                         Print Program: Cash Documents                              


What exactly are you doing.....anything here ring a bell?

Regards,

Rich Heilman

0 Kudos

Hi Srikanth,

Best way to know the print program is to findout which output type is being used for printing this script and then find out the print program using transaction NACE. A crude way is to look at table TNAPR and put your sapscipt name in the field for FORM.

Cheers,

Sanjeev

Former Member
0 Kudos

Hi Srikanth

The print program will have the code(logic) for the perform. All parameters (whether it is using or changing) is received in the print program in the internal table in_var which is of type itcsy.

Check the structure of itcsy and u will understand the details clearly.

Remember 2 reward points to replies that have answered ur question.

Regards,

PP.

former_member221770
Contributor
0 Kudos

Hi Srikanath,

Here is a quick example of how to use the PERFORM statement in SAPscript:

In SAPScript:

perform get_net_amount in program zinvoice01

using &GROSS_AMOUNT&

using &TAX_AMOUNT&

changing &NET_AMOUNT&

endperform.

In program ZINVOICE01:

form get_net_amount tables t_input structure itcsy

t_output structure itcsy.

data: l_gross type wrbtr,

l_tax type wrbtr,

l_net type wrbtr.

loop at t_input.

case i_input-name.

when 'GROSS_AMOUNT'.

l_gross = t_input-value.

when 'TAX_AMOUNT'.

l_tax = t_input-value.

endcase.

endloop.

endform.

l_net = l_gross - l_tax.

loop at t_output.

case t_output-name.

when 'NET_AMOUNT'.

t_output-value = l_net.

endcase.

modify t_output transporting value.

endloop.

Hope this points you in the right direction!

Cheers,

Pat.

PS. kindly assign reward points to the responses that you find helpful.

Former Member
0 Kudos

Hi,

Please see the code below,

In script

PERFORM GET_CUST_ADDRESS IN PROGRAM ZSHXS011_TESTING

using &vbdkr-adrnr&

changing &strt4&

changing &str5&

ENDPERFORM

In program

*intab contains input parameters

*process the intab values and populate into out_tab

form get_address tables in_tab structure itcsy

out_tab structure itcsy.

Data : addr1_sel like addr1_sel.

read table in_tab index 1. *adrnr value

if sy-subrc eq 0.

move in_tab-value to addr1_sel-addrnumber.

endif.

call function 'ADDR_GET'

exporting

address_selection = addr1_sel

importing

address_value = addr1_val

*assign street 4 to outtab

read table out_tab index 1.

if sy-subrc eq 0.

move addr1_val-str_suppl2 to out_tab-value.

modify out_tab index 1.

endif.

*assign street 5 to outtab

read table out_tab index 2.

if sy-subrc eq 0.

move addr1_val-str_suppl2 to out_tab-value.

modify out_tab index 2.

endif.

after the process we need to populate the values into outab.

Hope this will solve your problem.

Sasi