on 07-23-2007 1:18 PM
Using following perform in Sap script
PERFORM 'BANK_DETAILS' IN PROGRAM 'ZFI_PRN_BANK'
USING &BKPF-BELNR&
USING &BKPF-BUKRS&
USING &BKPF-GJAHR&
CHANGING &SAPSCRIPT-COUNTER_0&
CHANGING &SAPSCRIPT-COUNTER_1&
ENDPERFORM
Printing
&SAPSCRIPT-COUNTER_0&
&SAPSCRIPT-COUNTER_1&
The programs is written as
*----
REPORT ZFI_PRN_BANK .
TABLES : ITCSY.
TYPES : BEGIN OF F_TABLE ,
T_NAM LIKE ITCSY-NAME,
T_VAL LIKE ITCSY-VALUE,
END OF F_TABLE.
DATA : O_TABLE TYPE F_TABLE OCCURS 0 WITH HEADER LINE,
I_TABLE TYPE F_TABLE OCCURS 0 WITH HEADER LINE.
----
FORM BANK_DETAILS *
----
........ *
----
--> INPUT_TABLE *
--> OUTPUT_TABLE *
----
FORM BANK_DETAILS TABLES INPUT_TABLE LIKE I_TABLE[]
OUTPUT_TABLE LIKE O_TABLE[].
TABLES: BSEG,LFBK,BNKA.
DATA : DOC_NUM LIKE BSEG-BELNR,
COM_CODE LIKE BSEG-BUKRS,
F_YEAR LIKE BSEG-GJAHR,
T_NUM LIKE BSEG-BELNR,
T_VEN LIKE BSEG-LIFNR,
BANK_NAME LIKE BNKA-BANKA,
BNK_ACC LIKE LFBK-BANKN.
DATA : POS TYPE I.
DOC_NUM = '0000000000'.
READ TABLE INPUT_TABLE INDEX 1.
T_NUM = INPUT_TABLE-T_VAL.
POS = STRLEN( T_NUM ).
POS = 10 - POS.
MOVE T_NUM TO DOC_NUM+POS.
READ TABLE INPUT_TABLE INDEX 2.
COM_CODE = INPUT_TABLE-T_VAL.
READ TABLE INPUT_TABLE INDEX 3.
F_YEAR = INPUT_TABLE-T_VAL.
CLEAR T_NUM.
SELECT * FROM BSEG WHERE BELNR = DOC_NUM AND BUKRS = COM_CODE
AND GJAHR = F_YEAR.
CHECK SY-SUBRC = 0.
T_VEN = BSEG-LIFNR.
ENDSELECT.
REFRESH OUTPUT_TABLE.
SELECT SINGLE * FROM LFBK WHERE LIFNR = T_VEN
AND BANKS = 'IN'.
and bankl = bnk_code.
CHECK SY-SUBRC = 0.
BNK_ACC = LFBK-BANKN.
SELECT SINGLE * FROM BNKA WHERE BANKS = 'IN'
AND BANKL = LFBK-BANKL.
BANK_NAME = BNKA-BANKA.
MOVE 'SAPSCRIPT-COUNTER_0' TO OUTPUT_TABLE-T_NAM.
CONDENSE BANK_NAME.
POS = STRLEN( BANK_NAME ).
POS = POS - 1.
MOVE BANK_NAME TO OUTPUT_TABLE-T_VAL.
APPEND OUTPUT_TABLE.
CLEAR OUTPUT_TABLE.
MOVE 'SAPSCRIPT-COUNTER_1' TO OUTPUT_TABLE-T_NAM.
CONDENSE BNK_ACC.
POS = STRLEN( BNK_ACC ).
POS = POS - 1.
MOVE BNK_ACC(POS) TO OUTPUT_TABLE-T_VAL.
APPEND OUTPUT_TABLE.
CLEAR OUTPUT_TABLE.
ENDFORM. "get_bank
-
The value of SAPSCRIPT-COUNTER_0,SAPSCRIPT-COUNTER_1 is printing as 0, 0.
what could be the reason. Kindly help.
Thanks
anu
Hi
These SAPSCRIPT fields have values in the script itself
I think since you are using them in the Program(external Subroutine) I doubt whether they have values in program?
Try to removes the quotes on both sides of the fields and see.
<b>Reward points for useful Answers</b>
Regards
Anji
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another problem is that the values Bank name & account are not getting refreshed. Only first vendor has bank details but its getting printed on all the pages.
Have refreshed & cleared the internal tables in program.
Kindly resolve
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Anji , Davis
Initially removed ' ' from SAPSCRIPT-COUNTER_1 in perform in script & from program but no improvement.
Solved problem on my own. Refer to SAP help and came to know that OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
......
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
......
/: ENDPERFORM
The value were not getting printed as SAPSCRIPT-COUNTER_1 is of dec type.
So changes the perform as
PERFORM 'BANK_DETAILS' IN PROGRAM 'ZFI_PRN_BANK'
USING &BKPF-BELNR&
USING &BKPF-BUKRS&
USING &BKPF-GJAHR&
CHANGING &OUTVAR1&
CHANGING &OUTVAR2&
ENDPERFORM .
Program as
DATA : OUTVAR1(30) TYPE C,
OUTVAR2(20) TYPE C.
CONDENSE BANK_NAME.
POS = STRLEN( BANK_NAME ).
MOVE BANK_NAME TO OUTPUT_TABLE-T_VAL.
APPEND OUTPUT_TABLE.
CLEAR OUTPUT_TABLE.
MOVE 'OUTVAR2' TO OUTPUT_TABLE-T_NAM.
CONDENSE BNK_ACC.
POS = STRLEN( BNK_ACC ).
MOVE BNK_ACC(POS) TO OUTPUT_TABLE-T_VAL.
APPEND OUTPUT_TABLE.
CLEAR OUTPUT_TABLE.
Now Bank details are getting printed.
Thanks a lot for your help.
anu
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
SELECT * FROM BSEG WHERE BELNR = DOC_NUM AND BUKRS = COM_CODE
AND GJAHR = F_YEAR.
<b>CHECK SY-SUBRC = 0.</b>
T_VEN = BSEG-LIFNR.
ENDSELECT.
REFRESH OUTPUT_TABLE.
SELECT SINGLE * FROM LFBK WHERE LIFNR = T_VEN
AND BANKS = 'IN'.
and bankl = bnk_code.
<b>CHECK SY-SUBRC = 0.</b>
BNK_ACC = LFBK-BANKN.
SELECT SINGLE * FROM BNKA WHERE BANKS = 'IN'
AND BANKL = LFBK-BANKL.
BANK_NAME = BNKA-BANKA.
MOVE 'SAPSCRIPT-COUNTER_0' TO OUTPUT_TABLE-T_NAM.
CONDENSE BANK_NAME.
POS = STRLEN( BANK_NAME ).
POS = POS - 1.
MOVE BANK_NAME TO OUTPUT_TABLE-T_VAL.
APPEND OUTPUT_TABLE.
CLEAR OUTPUT_TABLE.
MOVE 'SAPSCRIPT-COUNTER_1' TO OUTPUT_TABLE-T_NAM.
CONDENSE BNK_ACC.
POS = STRLEN( BNK_ACC ).
POS = POS - 1.
MOVE BNK_ACC(POS) TO OUTPUT_TABLE-T_VAL.
APPEND OUTPUT_TABLE.
CLEAR OUTPUT_TABLE.
ENDFORM. "get_bank
You put check sy-subrc = 0.
so, if no value is retrieved , the bank name and account stays unchanged!
you should put:
if sy-subrc = 0.
do processing.
else.
MOVE space TO OUTPUT_TABLE-T_NAM.
MOVE space TO OUTPUT_TABLE-T_VAL.
'this will clear the return parameters.
endif.
Regards,
Sooness.
Anu, try this:
PERFORM BANK_DETAILS IN PROGRAM ZFI_PRN_BANK
USING &BKPF-BELNR&
USING &BKPF-BUKRS&
USING &BKPF-GJAHR&
CHANGING &SAPSCRIPT-COUNTER_0&
CHANGING &SAPSCRIPT-COUNTER_1&
ENDPERFORM
....
MOVE SAPSCRIPT-COUNTER_1 TO OUTPUT_TABLE-T_NAM.
CONDENSE BNK_ACC.
POS = STRLEN( BNK_ACC ).
POS = POS - 1.
MOVE BNK_ACC(POS) TO OUTPUT_TABLE-T_VAL.
APPEND OUTPUT_TABLE.
CLEAR OUTPUT_TABLE.
I took out the ' ' around the form and program name and SAPSCRIPT-COUNTER_1. I am not sure if they are allowed but I have never used them.
Davis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.