Pass subroutine to Sapscript
sir,
Like to know How we pass subroutine in sapscript and how standard texts are added and what is its command and transaction.
Edited by: Alvaro Tejada Galindo on Apr 28, 2008 4:45 PM
Subroutines in scripts:
Calling ABAP Subroutines: PERFORM
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (First page, Next page, Last page) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY PAGE.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY NEXTPAGE.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY BARCODE.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = |. "First page
ELSE.
OUT_PAR-VALUE = ||. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = L. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Similar Messages
-
Subroutine in sapscript for net due date
Hi,
This is the first time I am creating a subroutine for sapscript and I could not get it to work. I need to calculate the net due date using the baseline date plus cash discount days. But the form is just printing out 0000000. I am just trying to extract one due date here but I will have to get it for all line items then sort descending to get the latest one. Can anyone help me to see the gap why this is not working?
In the sapscript I have the following:
DEFINE &BASEDATE& = ®UP-ZFBDT&
DEFINE &PAYTERMS& = ®UP-ZBD1T&
PERFORM NET_DUE_DATE IN PROGRAM Z_SAPSCRIPT_FUNCTIONS
USING &BASEDATE&
USING &PAYTERMS&
CHANGING &DUEDATE&
ENDPERFORM
In program Z_SAPSCRIPT_FUNCTIONS
Thanks in advance!
CholenHi Raju!
I am really getting close! I did the conversion for all variables, however for VBLNR, it does not work. It gives leading zeroes but the value starts with a 'P' before the zeroes and the numeric value. I tried to remove that from the where clause and my select finally got something. However the output on the form is in the internal format. I suppose I should use CONVERT_DATE_TO_EXTERNAL which I tried doing after out_tab-value = lv_netduedate which is the variable I am passing to the form.
Raju Shrestha wrote:
Hi Cholen,
I believe your lv_laufd is a 10 character field in format MM/DD/YYY or DD/MM/YYYY. You should move that data to a 8 character variable (say lv_date) in YYYYDDMM format.
Please try this conversion
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = lv_laufd
IMPORTING
date_internal = lv_date
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
Check in debug, you should get lv_date in YYYYMMDD. Now use lv_date in your WHERE clause.
If you still do not get data after lv_date eq YYYYMMDD, check your LIFNR and KUNNR. They should be 10 charaters with leading zeroes if not 10 .
If needed use the conversion for lv_lifnr and lv_kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
date_external = lv_lifnr
IMPORTING
date_internal = lv_lifnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
date_external = lv_kunnr
IMPORTING
date_internal = lv_kunnr.
Cheers,
Raju. -
Problem in calling ABAP Subroutine from SAPSCRIPT
Hi,
I need to get the reason for cancellation of a Business Even in Training & Event Management module, so I am passing Emp_id.
But the reason(CAAATRT) is returned with blank by the code.
please help.
/:DEFINE &EMP_ID&= &PPVAR-TOBJD&
/:PERFORM HR_REASON_PRINT IN PROGRAM ZHR_REASON_PRINT
/:USING &EMP_ID&
/:CHANGING &CAATRT&
REPORT ZHR_REASON_PRINT.
DATA : BEGIN OF in_par OCCURS 10.
INCLUDE STRUCTURE itcsy.
DATA : END OF in_par.
DATA : BEGIN OF out_par OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA : END OF out_par.
DATA: TOBJD TYPE PPVAR-TOBJD,
ADATANR TYPE HRP1001-ADATANR,
CAATR TYPE HRPAD25-CAATR,
CAATRT TYPE T77CART-CAATRT,
EMP_ID TYPE C.
TABLES : PPVAR,
HRP1001,
HRPAD25,
T77CART.
FORM HR_REASON_PRINT TABLES input output.
in_par[] = input[].
out_par[] = output[].
READ TABLE in_par INDEX 1.
CHECK sy-subrc = 0.
TOBJD = in_par-value.
MOVE in_par-value TO TOBJD.
SELECT ADATANR
into ADATANR
FROM HRP1001
WHERE OBJID EQ TOBJD.
ENDSELECT.
SELECT CAATR
into CAATR
FROM HRPAD25
WHERE ADATANR EQ ADATANR.
ENDSELECT.
SELECT CAATRT
INTO CAATRT
FROM T77CART
WHERE CAATR EQ CAATR.
ENDSELECT.
REFRESH out_par.
out_par-name = 'DREASON'.
move CAATRT To out_par-value.
MODIFY out_par INDEX 1.
APPEND out_par.
output[] = out_par[].
Thanks
RamakrishnaHi ramakrishna,
1. while calling subroutines from sapscripts,
there is a special technique,
which has got its own limitations.
2.
FORM abc
TABLES
in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
ENDFORM.
3. The perform in se38 program should be of the
above format only.
4. We cannot pass internal tables.
5. Rather we need to pass
VARIABLE NAME
VARIABLE VALUE
(see the structure of itcsy in se11)
6. In this form, we have to read
the internal table in_tab
to capture the variable name and its value.
7. Similary, to return the values,
we have to put one record (for each variable)
in out_tab.
regards,
amit m. -
Calling subroutine in sapscript
can anyone guide how 2 call subrouting in sapscript and i need sample code...i need a simple code how 2 call and implement
so tat it ll be easy 4 me learn..hi,
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
The system does not execute the PERFORM command within SAPscript replace modules, such as TEXT_SYMBOL_REPLACE or TEXT_INCLUDE_REPLACE. The replace modules can only replace symbol values or resolve include texts, but not interpret SAPscript control commands.
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (First page, Next page, Last page) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
Coding of the calling ABAP program:
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY PAGE.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY NEXTPAGE.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY BARCODE.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = |. "First page
ELSE.
OUT_PAR-VALUE = ||. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = L. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
regards,
veeresh -
Use of subroutine in SapScript
Hi Friends,
I am passing two parameters as input from sapscript perform statement and i want one field from database table as output.
In abap editor i have created two internal tables of the type ITCSY for input and output parameters. <b>The name field of the internal table i have created is getting populated but the corresponding value field is not getting populated,</b> so my further logic is not processed and i am not gettin the desired result i.e. it it displaying nothing.
Can you guide me on the same?
Regards,
NikhilHi,
My code is as follows in which i have ynbemployeetable in database from which i am taking empname and empgender as input and i want empid as output.
I have written following perform statement in se71.
PERFORM GET_DETAILS IN PROGRAM ZNIK_SSCRIPT_NEW_AS5
USING &YNBEMPLOYEETABLE-EMPNAME&
USING &YNBEMPLOYEETABLE-EMPGENDER&
CHANGING &EMPID&
ENDPERFORM
I have written following form in se38 abap editor. in this the input-value field is not getting populated.
FORM get_details TABLES input STRUCTURE ITCSY
output STRUCTURE ITCSY.
DATA : z_empname LIKE ynbemployeetable-empname,
z_empgender LIKE ynbemployeetable-empgender,
z_empid type i.
READ TABLE input with key 'YNBEMPLOYEETABLE-EMPNAME'.
CHECK sy-subrc = 0.
z_empname = <b>input-value</b>. "Not getting populated
READ TABLE input with key 'YNBEMPLOYEETABLE-EMPGENDER'.
CHECK sy-subrc = 0.
z_empgender = <b>input-value.</b> "Not getting populated
SELECT SINGLE empid FROM ynbemployeetable
INTO z_empid
WHERE empname = z_empname and empgender = z_empgender.
output-name = 'EMPID'.
MOVE z_empid TO output-value.
MODIFY output INDEX 1.
ENDFORM.
Can you help me know why it is not getting populated and what is the mistake? -
Use of subroutines in SAPScripts
When we are calling a subroutine from Script is it possible to retrieve an internal table from the program and use it in the script for printing data?
for eg:PERFORM <subroutine name> IN PROGRAM <program name> using<var1>
chnging<var2>.Can Var1 or var 2 be an internal table?hi Savitha,
Var1 and Var2 are defintely tables, but does not serve the purpose of passing internal table values from print program. They are tables of structure ITCSY which has only two fields, NAME (field name) and VALUE (field value). Meaning for one field, there can be only one entry.
Please see the code attached below:
PERFORM get_attn IN PROGRAM zprogname USING var1 CHANGING var2.
FORM get_attn TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA: v_name2 TYPE kna1-name2,
v_attn TYPE string,
v_kunnr TYPE knvk-kunnr,
v_offset TYPE i,
err_str TYPE string,
w_tab TYPE itcsy.
* Get Customer Number
READ TABLE in_tab INTO w_tab WITH KEY name = 'DKADR-KONTO'.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
INTO err_str .
ENDIF.
* Get Assistant name
MOVE w_tab-value TO v_kunnr.
v_offset = 10 - STRLEN( v_kunnr ).
SHIFT v_kunnr RIGHT BY v_offset PLACES.
OVERLAY v_kunnr WITH '0000000000'.
SELECT SINGLE name2 FROM kna1 INTO v_name2
WHERE kunnr = v_kunnr.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
INTO err_str .
ENDIF.
CLEAR w_tab.
READ TABLE out_tab WITH KEY name = 'ATT_NAME' INTO w_tab.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
INTO err_str .
ENDIF.
MOVE v_name2 TO w_tab-value.
MODIFY out_tab INDEX sy-tabix FROM w_tab.
ENDFORM. "get_attn
Hope this helps,
Sajan Joseph. -
Calling subroutines from SAPScript
Hi all,
I have added a piece of code in my MAIN window which calls a subroutine in another program. This works just fine. However, when I moved the code from one <b>window element</b> of MAIN to another, the code is no longer triggered.
What causes this to happen? Is it related to the calling of function module WRITE_FORM in the application program? Any ideas?
All helpful answers will be rewarded!
Regards,
M.V.Hi,
In some case we need to do some mathematical operations in scripts !! Those things we cant do in Script Editor !! thats y the subroutines are there in scripts !!
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
Syntax in a form window:
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:
FORM <form> TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
ENDFORM.
Regards
Rama.Pammi -
Debuggin External subroutine in sapscript
Hi Gurus,
I need to debug external soubroutine written in sapscript.i am not getting how to proceed for this.please help me.
Regards
Sam
Moderator message: sapscript debugging = FAQ, please search before posting.
Edited by: Thomas Zloch on Oct 27, 2010 1:25 PMHi,
I think this may help
Place a break point in your subroutine, now activate the sap script debugger.
Press F5 and continue debugging in sap script once it reaches the statement where the routine is called it will take you to the code.
regards -
External subroutine in sapscript
hi all
can anyone explain me how to handle an external subroutine in a script with a simple example.
rg
sandeepHi Sandeep,
Try this :
Use PERFORM from SAPSCRIPT
/: PERFORM BIN_LOCATION IN PROGRAM Z_SAPSCRIPT_PERFORMS
/: USING &RESBD-MATNR&
/: USING &CAUFVD-IWERK&
/: USING &RESBD-LGORT&
/: CHANGING &MARD-LGPBE&
/: ENDPERFORM
REPORT z_sapscript_performs.
SUBROUTINES FOR CALLING FROM SAPSCRIPTS
FORM bin_location TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
get default bin location from MARD for this material/plant/storage *
location
DATA: l_matnr TYPE matnr, "material
l_werks TYPE werks, "plant
l_lgort TYPE lgort, "storage location
l_lgpbe TYPE lgpbe. "bin location
Get first parameter in input table.
READ TABLE in_tab INDEX 1.
WRITE in_tab-value TO l_matnr .
Get second parameter in input table
READ TABLE in_tab INDEX 2.
MOVE in_tab-value TO l_werks.
Get third parameter in input table
READ TABLE in_tab INDEX 3.
MOVE in_tab-value TO l_lgort.
read bin location
SELECT SINGLE lgpbe INTO l_lgpbe FROM mard
WHERE matnr = l_matnr
AND werks = l_werks
AND lgort = l_lgort.
IF l_LGPBE IS INITIAL.
l_LGPBE = 'NONE'.
ENDIF.
read & update only parameter in output table
READ TABLE out_tab INDEX 1.
out_tab-value = l_lgpbe.
MODIFY out_tab INDEX 1.
ENDFORM.
Regards,
Lanka -
PROBLEM IN SUBROUTINE IN SAPSCRIPT!
CAUFVD IS A STRUCTURE. WHICH HAS ORDER NO 10000427.
IAM USING CAUFVD COZ RESB-AUFNR IN PERFORM DOESNOT GIVE A VALUE IN SAP SCRIPT.
CAUFVD-AUFNR = 10000427
RESB-AUFNR IN SE11 GIVES THE FOLLOWING.
RESB-AUFNR = 000010000427
RESB-RSNUM = 0000005126
PROBLEM IS THAT IN SELECTION ITS PICKING 10000427 WHEREAS I NEED 000010000427.
HOW DO I DO THIS?
PLEASE MENTION COMPLETE STEPS OR MODIFY THE EXISTING.
PERFORM YE_PM_COMMON_RESERV_PR IN PROGRAM ZPMLINCLUDE
USING &CAUFVD-AUFNR& "RESB-AUFNR WONT WORK. SO IAM USING CAUFVGD-AUFNR.
CHANGING &CONV_RESERV&
CHANGING &CONV_PR&
CHANGING &CONV_PR&
ENDPERFORM.
PERFORM ZPM_COMMON IN PROGRAM ZPMLINCLUDE
USING &CAUVFD-AUFNR& "ORDER NO
CHANGING &CONV_RESERV&
ENDPERFORM.
FORM ZPM_COMMON
TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA : V_AUFNR TYPE RESB-AUFNR, "ORDER NO
V_RSNUM TYPE RESB-RSNUM. "RESERVATION NUMBER
READ TABLE IN_TAB INDEX 1.
MOVE IN_TAB-VALUE TO V_AUFNR.
SELECT SINGLE RSNUM FROM RESB INTO V_RSNUM
WHERE AUFNR = V_AUFNR.
READ TABLE OUT_TAB INDEX 1.
OUT_TAB-VALUE = V_RSNUM.
MODIFY OUT_TAB INDEX 1.
CLEAR OUT_TAB.
ENDFORM.
REGARDS
ESSAM ([email protected])Hi
Check out the changes in BOLD
FORM ZPM_COMMON
TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA : V_AUFNR TYPE RESB-AUFNR, "ORDER NO
V_RSNUM TYPE RESB-RSNUM. "RESERVATION NUMBER
READ TABLE IN_TAB INDEX 1.
MOVE IN_TAB-VALUE TO V_AUFNR.
**CALL THIS FUNCTION TO CONVERT FOR OUTPUT FORMAT TO
***INTERNAL FORMAT I.E WITH LEADING 0.
<b>CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
Exporting
INPUT = V_AUFNR
Importing
OUTPUT = V_AUFNR.</b>
SELECT SINGLE RSNUM FROM RESB INTO V_RSNUM
WHERE AUFNR = V_AUFNR.
READ TABLE OUT_TAB INDEX 1.
<b>**OUT_TAB-VALUE = V_RSNUM.</b><b>write v_rsnum to out_tab-value left-justified.</b>
MODIFY OUT_TAB INDEX 1.
CLEAR OUT_TAB.
ENDFORM.
<b>Reward if Helpful.</b> -
Passing Internal table to SAPscript from report
Hi Experts..
I have a requirement of sending Rate Change notification to the business partner and the code of which is written in SAPscript
I've written the query part in driver program but I am unable to send the vkonto(Contract Account) which is in internal table(IT_EVER) to the SAPscript, though I am using OPEN_FORM, WRITE_FORM and CLOSE_FORM function modules, but still I am unable to get the values in SAPscript.. I unable to pass IT_EVER to SAPscript..
SELECT-OPTIONS: S_VKONT FOR FKKVKP-VKONT MODIF ID TT. " Contract Account Number
SELECT VERTRAG ANLAGE VKONTO INTO TABLE IT_EVER FROM EVER WHERE VKONTO IN S_VKONT.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX' " Standard Text
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = ' '
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.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = ' '
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.
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.but where do i have to write the SAPscript's name in the function module? And where do I have to write IT_EVER internal table which I want to pass to SAPscript..
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX' " Standard Text
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = ' '
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 IT_EVER INTO WA_EVER.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = ' '
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. -
Hi All
can anybody plz tell me waht is subroutine pool of sapscript??
waiting for replies
THanksHi,
If you want to do calculations on some of the fields in a script one way is to change the print program. And other way is to call a routine in the windw which is in another program.
For eg: if you have a subroutine named ADD_INCOME in a program ZSHAIL_BASIC, you can call the subroutine in SAPScript as follows:
/: PERFORM ADD_INCOME IN PROGRAM ZSHAIL_BASIC
/: USING &var1&
/: CHANGING &var2&
/: ENDPERFORM.
Here the input parameter to the subroutine is var1 and the value returned by the subroutine is var2.
In the program ZSHAIL_BASIC, you have to call the subroutine as
FORM ADD_INCOME TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
ENDFORM.
IN_TAB is a structure of type ITCSY,which has 2 components, NAME and value.
So in the program, var1(which is sent from SAPScript) , will be stored as IN_TAB-NAME and its value will be in IN_TAB-VALUE. You can utilise the IN_TAB-VALUE and after performing the required operations, the return value should be assigned to table OUT_TAB.
This value can thus be obtained in var2 specified in SAPScript.
Thanks and Regards,
Bharat Kumar Reddy.V -
hii guys,
1. provide me a example program for subroutine call
2. as i want add fielda in form
3.provide me driver program not only step or u provide me
1. driver program
2. field i want to add in driver program as well as in form.
3. steps by step.
regards
rahulHi
No need of touching the original Driver program
Write a perform in Script and program in SE38 and do
see the examples
How to call a subroutine form SAPscripts
The Form :
/:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
/:USING &EKKO-EBELN&
/:CHANGING &CDECENT&
/:ENDPERFORM
The report :
REPORT zkrpmm_perform_z1medruck .
DATA : BEGIN OF it_input_table OCCURS 10.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_input_table.
déclaration de la table output_table contenant les
variables exportées
DATA : BEGIN OF it_output_table OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA : END OF it_output_table.
DATA : w_ebeln LIKE ekko-ebeln,
w_vbeln LIKE vbak-vbeln,
w_zcdffa LIKE vbak-zcdffa.
FORM CDE_CENT
FORM cde_cent TABLES input output.
it_input_table[] = input[].
it_output_table[] = output[].
READ TABLE it_input_table INDEX 1.
MOVE it_input_table-value TO w_ebeln.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_ebeln
IMPORTING
output = w_ebeln.
SELECT SINGLE zcdffa FROM ekko
INTO w_zcdffa
WHERE ebeln = w_ebeln.
it_output_table-name = 'CDECENT'.
MOVE w_zcdffa TO it_output_table-value.
MODIFY it_output_table INDEX 1.
output[] = it_output_table[].
ENDFORM.
/: PERFORM
/: USING &INVAR1&
/: USING &INVAR2&
/: CHANGING &OUTVAR1&
/: CHANGING &OUTVAR2&
/: ENDPERFORM
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.
OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
Example:
In script form
/: PERFORM READ_TEXTS IN PROGRAM 'Z08M1_FORM_EKFORM1'
/: USING &EKKO-EKORG&
/: USING &EKPO-WERKS&
/: USING &EKKO-EKGRP&
/: USING &EKKO-BSTYP&
/: CHANGING &COMPNAME&
/: CHANGING &SENDADR&
/: CHANGING &INVCADR&
/: CHANGING &COMPADR&
/: CHANGING &COVERLTR&
/: CHANGING &SHIPADR&
/: CHANGING &REMINDER&
/: CHANGING &REJECTION&
/: CHANGING &POSTADR&
/: CHANGING &LOGO&
/: ENDPERFORM
In program
FORM Read_texts - To extract the standard texts from the table *
FORM READ_TEXTS TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA : L_EKORG TYPE EKORG,
L_WERKS TYPE WERKS_D,
L_BSTYP TYPE BSTYP,
L_EKGRP TYPE BKGRP.
READ TABLE IN_PAR WITH KEY 'EKKO-EKORG' .
CHECK SY-SUBRC = 0.
L_EKORG = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKPO-WERKS' .
CHECK SY-SUBRC = 0.
L_WERKS = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKKO-EKGRP' .
CHECK SY-SUBRC = 0.
L_EKGRP = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY 'EKKO-BSTYP' .
CHECK SY-SUBRC = 0.
L_BSTYP = IN_PAR-VALUE.
CLEAR Z08M1_ORG_TEXTS.
SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = L_BSTYP.
IF SY-SUBRC NE 0.
SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
AND WERKS = L_WERKS
AND EKGRP = L_EKGRP
AND BSTYP = SPACE.
ENDIF.
READ TABLE OUT_PAR WITH KEY 'COMPNAME'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COMP.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'SENDADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_ADRS.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'INVCADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_INVC.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'COMPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_CPAD.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'COVERLTR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COVR.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'SHIPADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_SHIP.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'REMINDER'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RMDR.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'REJECTION'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RJCT.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'POSTADR'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_POST.
MODIFY OUT_PAR INDEX SY-TABIX.
READ TABLE OUT_PAR WITH KEY 'LOGO'.
OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_LOGO.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
REPORT ZMPO1 .
form get_freight tables in_par structure itcsy out_par structure itcsy.
tables: ekko,konv,t685t.
data: begin of itab occurs 0,
ebeln like ekko-ebeln,
knumv like ekko-knumv,
end of itab.
data: begin of itab1 occurs 0,
knumv like konv-knumv,
kposn like konv-kposn,
kschl like konv-kschl,
kbetr like konv-kbetr,
waers like konv-waers,
kwert like konv-kwert,
end of itab1.
data: begin of iout occurs 0,
kschl like konv-kschl,
vtext like t685t-vtext,
kbetr like konv-kbetr,
kwert like konv-kwert,
end of iout.
data v_po like ekko-ebeln.
read table in_par with key 'EKKO-EBELN'.
if sy-subrc = 0.
v_po = in_par-value.
select
ebeln
knumv
from ekko
into table itab
where ebeln = v_po.
if sy-subrc = 0.
loop at itab.
select
knumv
kposn
kschl
kbetr
waers
kwert
into table itab1
from konv
where knumv = itab-knumv and
kappl = 'M'.
endloop.
loop at itab1.
if itab1-kposn <> 0.
select single * from t685t
where kschl = itab1-kschl
and kappl = 'M'
and spras = 'EN'.
iout-vtext = t685t-vtext.
iout-kschl = itab1-kschl.
iout-kbetr = itab1-kbetr.
iout-kwert = itab1-kwert.
append iout.
clear iout.
endif.
endloop.
sort itab1 by kposn.
loop at iout.
sort iout by kschl.
if ( iout-kschl eq 'GSDC' OR
iout-kschl eq 'GSFR' OR
iout-kschl eq 'GSIR' ).
at end of kschl.
read table iout index sy-tabix.
sum.
write:/ iout-kschl,iout-vtext,iout-kwert.
out_par-name = 'A1'.
out_par-value = iout-vtext.
append out_par.
out_par-name = 'A2'.
out_par-value = iout-kwert.
append out_par.
endat.
endif.
endloop.
endif.
endif.
endform.
IN THE FORM I AM WRITING THIS CODE.
/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:PERFORM GET_FREIGHT IN PROGRAM ZMFORM_PO1
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:ENDPERFORM
&A1&
&A2&
This Code is to be written in the PO form under ADDRESS window.
/:DEFINE &A1& = ' '
/:DEFINE &A2& = ' '
/:DEFINE &A3& = ' '
/:DEFINE &A4& = ' '
/:DEFINE &A5& = ' '
/:DEFINE &A6& = ' '
/:PERFORM GET_VENDOR IN PROGRAM ZMFORM_PO
/:USING &EKKO-EBELN&
/:CHANGING &A1&
/:CHANGING &A2&
/:CHANGING &A3&
/:CHANGING &A4&
/:CHANGING &A5&
/:CHANGING &A6&
/:ENDPERFORM
&A1&
&A2&
&A3&
&A4&
&A5&
&A6&
Regards
Anji -
Use of subroutine entry in form processing
Hi,
Can anybody pls explain the use of subroutine ENTRY and what it has got to do with output type. Im working on script and smartforms and need to know the process behind it. I hope i explained my question well.
Rgds
SidYour configuration usually points to a formname, a program, and an start subroutine for SAPScript, at least. SAP routinely named the start subroutine ENTRY. Inside ENTRY, you will see that what usually happens is a reference to the structure NAST, where output controls, like copy counters, etc., and the document number (OBJKY) are stored and passed into the output form driver program.
-
How to print top of page while displaying data in ALV Grid ........as i m passing subroutine for top of page' in parameter i_callback_html_top_of_page
i_callback_html_top_of_page is different than i_callback_top_of_page...
if you want to use callback_html you will need to define a form routine something like this:
form html_top_of_page using r_top type ref to cl_dd_document.
data: text type sdydo_text_element.
* data: s_table type ref to cl_dd_table_element.
* data: col_key type ref to cl_dd_area.
* data: col_info type ref to cl_dd_area.
data: a_logo type ref to cl_dd_area.
data:
l_string_with_html type string, "WA Html String Handling
l_text_wa(20) type c. "WA String Handling
call method r_top->initialize_document.
** Set Background Color on TOP-document = small white square works well
* this should be a graphic stored in BDS
call method r_top->set_document_background
exporting picture_id = 'SmWhiteSquare'.
** split TOP-Document to make space for the logo on the right
call method r_top->vertical_split
exporting split_area = r_top
split_width = '70%'
importing right_area = a_logo.
** and add a Company logo - stored in BDS as above
call method a_logo->add_picture
exporting picture_id = 'YourLogoHere'.
** fill TOP-Document space on the left with data
* first the title
text = sy-repid. " 'Var with My report name'.
call method r_top->add_text exporting text = text
sap_style = 'HEADING'.
call method r_top->new_line.
* your code here (may list report selections params or whatever)...
endform.
Maybe you are looking for
-
How can I see the entire feed in a Podcast
I have downloaded This American Life but cannot see the entire feed. How can I fix that?
-
Adobe Creative Cloud Not Loading Correctly Windows 7 Pro Sp1
When I open CC, the below screenshot is what I get: System specs are as follows: Processors: 8 Video Card: Nvidia Quadro 2000D All Adobe products are trusted within Kaspersky. Kaspersky logs indicate that Adobe CC is not being blocked in any way. Ado
-
[Forms10g (9.0.4)] error 310 with %ROWTYPE
I have a package specification in which i declare a user defined type and a function: SUBTYPE services_record_type IS services%ROWTYPE; FUNCTION services(services_record IN OUT services_record_type) RETURN BOOLEAN; When i compile, i am getting this e
-
hi. I'm new to Java. Installed JAva from a book's CD. Java1.3. When I compile, I get an error message saying "bad command or file name". It doesn't compile. Thank goodness for the book's exercises being on CD. The .class files are already there, whic
-
Many times when logging in (seems to be manly when I start by clicking 'my questions' - I also have this bookmarked because it's the most sensible place for me to start when visiting these discussion forums) I get an error saying "page not found". Th