on 10-28-2008 10:32 AM
Hi,
Actually I developed a script; from there I am calling a subroutine program.
I am passing a vendor number to the program from script, using that I am getting some values in internal table.
In the program I am using the function module u2018Write_formu2019 by looping the internal table to pass the values and print it in the script, but the values are not moving into script.
We can achieve it another way by passing the values from driver program, but mine is a standard one, so I canu2019t change it.
Please find the code of script & subroutine program.
Script syntax:
/: DEFINE &LS_ITAB& = .
/E PLANT_HEAD
/: PERFORM FETCH_CONSIGN_DATA IN PROGRAM
YTEST_CONSIGN_SUBROUTINE_POOL
/: USING &INVAR1&
/: ENDPERFORM.
/E TEST
IA &ls_itab-vbeln&
********************************xx******************************************************
Subroutine program:
&----
*& Subroutine Pool ZMM_CONSIGN_SUBROUTINE_POOL
*&
&----
*&
*&
&----
REPORT ytest_consign_subroutine_pool.
************************************************************************
tables *
************************************************************************
TABLES: VBUP,
/nfm/tprovhis.
TYPES: begin of t_itab,
nes type /nfm/tprovhis-nes,
autyp type /nfm/tprovhis-autyp,
menge type /nfm/tprovhis-menge,
matnr type /nfm/tprovhis-matnr,
parnr type /nfm/tprovhis-parnr,
end of t_itab.
data: i_itab type standard table of t_itab ,
ls_itab type t_itab.
&----
*& Form fetch_consign_data
&----
text
----
--> in_tab text
<-- out_tab text
----
FORM fetch_consign_data TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
*Select all open orders & line item number for the customer
SELECT nes autyp menge kunnr matnr parnr datum
FROM /nfm/tprovhis
INTO corresponding fields of table i_itab
WHERE parnr EQ '0001030506' AND
nes EQ '109' AND
werks EQ '2075'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZMM_VENDCONS'
LANGUAGE = SY-LANGU
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
SPONUMIV =
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT i_itab INTO ls_itab.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TEST'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "fetch_consign_data
Kindly let me know your suggestion .
<MOVED BY MODERATOR TO THE CORRECT FORUM>
Edited by: Alvaro Tejada Galindo on Oct 28, 2008 11:01 AM
Hi,
You can't use OPEN_FORM, WRITE_FORM etc in Subroutine program of a SAPScript, Subroutines are used in SAPScript to fetch values which are not fetched by a standard driver program.
You can use CHANGING value in your PERFORM statement and get the values back to the SAPScript and get print.
Ex:-
SAPScript
/:PERFORM GET_COMCODE IN PROGRAM ZM_RFQ_REJECTION
/:USING &EKKO-BUKRS&
/:USING &EKKO-SPRAS&
/:CHANGING &SADR-NAME1&
/:CHANGING &SADR-NAME2&
/:CHANGING &SADR-NAME3&
/:CHANGING &SADR-PSTLZ&
/:CHANGING &SADR-NAME4&
/:ENDPERFORM
Subroutine program
DATA : w_ebeln TYPE ekpo-ebeln, "RFQ document number
w_ebelp TYPE ekpo-ebelp, "Item number
w_spras TYPE ekko-spras, "Language
w_agmem TYPE ekpo-agmem, "Rejection condition
w_agtxt TYPE tmamt-agtxt. "Rejection text
Vendor contact person
DATA : w_verkf TYPE ekko-verkf. "Vendor contact person
Company address according to Company code
DATA : w_bukrs TYPE ekko-bukrs, "Company code
w_name1 TYPE t001-butxt, "Company name
w_rcomp TYPE t001-rcomp, "
w_stret TYPE t880-stret, "Street address
w_pstlc TYPE t880-pstlc, "Postal code
w_ort01 TYPE t001-ort01, "City
w_city TYPE t880-city, "City
w_landx TYPE t005t-landx, "Country name
w_land1 TYPE t001-land1. "Country code
FORM get_comcode TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
READ TABLE in_tab INDEX 1.
w_bukrs = in_tab-value.
READ TABLE in_tab INDEX 2.
w_spras = in_tab-value.
SELECT butxt
rcomp
land1 FROM t001 INTO (w_name1, w_rcomp, w_land1)
WHERE bukrs = w_bukrs.
SELECT SINGLE stret
pstlc
city FROM t880 INTO (w_stret, w_pstlc, w_city)
WHERE rcomp = w_rcomp.
SELECT SINGLE landx FROM t005t INTO w_landx
WHERE land1 = w_land1
AND spras = w_spras.
ENDSELECT.
READ TABLE out_tab INDEX 1.
MOVE w_name1 TO out_tab-value.
MODIFY out_tab INDEX sy-tabix.
READ TABLE out_tab INDEX 2.
MOVE w_stret TO out_tab-value.
MODIFY out_tab INDEX sy-tabix.
READ TABLE out_tab INDEX 3.
MOVE w_city TO out_tab-value.
MODIFY out_tab INDEX sy-tabix.
READ TABLE out_tab INDEX 4.
MOVE w_pstlc TO out_tab-value.
MODIFY out_tab INDEX sy-tabix.
READ TABLE out_tab INDEX 5.
MOVE w_landx TO out_tab-value.
MODIFY out_tab INDEX sy-tabix.
ENDFORM. "get_comcode
Regards
Bala Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.