2007 Apr 18 4:05 PM
hi friends pls tell
how we use ITCSY structure in script. pls tell how to add two fields in paricular
window of a standard script like rvorder01 without distrubing its print program .
give some coding in that windows line editor .
and also give coding for print program(i mean how to use that structure in that program) r adding that two fields in same winndow or or seperate new window.
2007 Apr 18 4:24 PM
Hi Sunil,
Regarding ITCSY:
Performing an ABAP form
The logic possible in SAPscript code is limited. And no arithmetic, no database queries. Not much at all, in fact, but enough for the primary function of SAPscript.
These limitations can be circumvented by calling an ABAP form using PERFORM.
Is this a good idea? Often the logic would be better in the print program.
Sometimes, however, the config does not let us have our own print program. Or we choose not to have our own print program. Or the print program might be hard to follow.
The bad news is that there are severe restrictions on the parameters of an ABAP form called from SAPscript. The only parameters must be two TABLES, each with dictionary structure ITCSY. The first table is used for the input values, and the second for the output values.
Warning: These tables are of the old style with a header line. When the form is called, the table header lines are not necessarily in their initial state, since there can be several PERFORMs [of form(s) with identically-named TABLES] in the printing of a single document. This can cause obscure bugs.
An ABAP form called from SAPscript needs to be in an ABAP program. We have a number of such programs, and they have names beginning ZSAPSCRIPT.
Each of these ABAP programs is not just a collection of forms, but has been made executable for testing purposes, which is now our standard approach. To this end, there is a selection screen for the entry of parameters. Mostly, this testing is very helpful, and can even be done in the production client. However, there are some caveats.
The form might depend on data available only when a document is being printed. E.g. it might IMPORT FROM SHARED MEMORY.
In many cases, data from the selection screen will be in internal format, since it will have undergone input conversion. For instance, a sales-order number 69123456 on the selection screen could be converted to the internal value 0069123456. We would therefore be testing with the value 0069123456, and not testing with 69123456. This could be averted by making the selection-screen parameters of type C.
One of our forms actually creates a database record, or can do if a checkbox is checked.
Sample ABAP form:
FORM GET_CUST_DUNN_CLERK TABLES IN_V STRUCTURE ITCSY
OUTV STRUCTURE ITCSY.
DATA:
F_KUNNR LIKE KNA1-KUNNR,
F_BUKRS LIKE T001S-BUKRS,
F_MABER LIKE T047M-MABER,
F_SNAME LIKE T001S-SNAME,
F_TEL_NUMBER LIKE ADCP-TEL_NUMBER,
F_TEL_NUMBER_I LIKE ADCP-TEL_NUMBER,
F_FAX_NUMBER LIKE ADCP-FAX_NUMBER,
F_FAX_NUMBER_I LIKE ADCP-FAX_NUMBER.
READ TABLE IN_V INDEX 1. F_KUNNR = IN_V-VALUE.
READ TABLE IN_V INDEX 2. F_BUKRS = IN_V-VALUE.
READ TABLE IN_V INDEX 3. F_MABER = IN_V-VALUE.
PERFORM GET_CUST_DUNN_CLERK_A
USING F_KUNNR F_BUKRS F_MABER
CHANGING F_SNAME F_TEL_NUMBER F_TEL_NUMBER_I
F_FAX_NUMBER F_FAX_NUMBER_I.
The "_I" suffix indicates an international version of a number.
OUTV-VALUE = F_SNAME. OUTV-NAME = 'DC_NAME'. APPEND OUTV.
OUTV-VALUE = F_TEL_NUMBER. OUTV-NAME = 'DC_TELNO'. APPEND OUTV.
OUTV-VALUE = F_TEL_NUMBER_I. OUTV-NAME = 'DC_TELNO_I'. APPEND OUTV.
OUTV-VALUE = F_FAX_NUMBER. OUTV-NAME = 'DC_FAXNO'. APPEND OUTV.
OUTV-VALUE = F_FAX_NUMBER_I. OUTV-NAME = 'DC_FAXNO_I'. APPEND OUTV.
ENDFORM. " GET_CUST_DUNN_CLERK
Example of corresponding SAPscript PERFORM:
/: PERFORM GET_CUST_DUNN_CLERK IN PROGRAM ZSAPSCRIPT_USERS
/: USING &VBDKR-KUNAG&
/: USING &VBDKR-VKORG&
/: USING &DUNN_AREA&
/: CHANGING &DC_NAME&
/: CHANGING &DC_TELNO&
/: CHANGING &DC_TELNO_I&
/: CHANGING &DC_FAXNO&
/: CHANGING &DC_FAXNO_I&
/: ENDPERFORM
Notice that the real processing is in the form GET_CUST_DUNN_CLERK_A (not shown). This means that we have a version of the form for calls from SAPscript (GET_CUST_DUNN_CLERK) and a version of the form more suitable for calls from ABAP (GET_CUST_DUNN_CLERK_A) without duplicating code.
We have adopted this two-form approach as our standard.
John
2007 Apr 18 4:37 PM
Hi Sunil
he structure ITCSY is used in relation with SAPScripts. You can call a Routine in any program in SAPScript.
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.
Check this standard help
http://help.sap.com/saphelp_46c/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm
In sap scripts, there are certain cases where we need to use some external subroutines which should be called by the script to achieve certain functionality. So these external subroutines are defined with an input and output structure which is of type ITCSY.
FORM F_GET_HEADER_DETAILS TABLES ITAB STRUCTURE ITCSY
OTAB STRUCTURE ITCSY.
Warehouse number
CLEAR V_LGNUM.
READ TABLE ITAB WITH KEY NAME = 'LTAK-LGNUM'
TRANSPORTING VALUE.
V_LGNUM = ITAB-VALUE.
*-Get TO number
CLEAR V_TO_NO.
READ TABLE ITAB WITH KEY NAME = 'LTAK-TANUM'
TRANSPORTING VALUE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = ITAB-VALUE
IMPORTING
OUTPUT = V_TO_NO.
OTAB-VALUE = V_TO_NO.
MODIFY OTAB TRANSPORTING VALUE WHERE NAME = 'TO_NO'.
*-Get Plant
READ TABLE ITAB WITH KEY NAME = 'LTAP-WERKS'
TRANSPORTING VALUE.
*-Get Company Name
CLEAR V_COMPANY_NAME.
SELECT T001~BUTXT INTO V_COMPANY_NAME
UP TO 1 ROWS
FROM T001K JOIN T001
ON T001KBUKRS = T001BUKRS
WHERE BWKEY = ITAB-VALUE(4).
ENDSELECT.
IF SY-SUBRC = 0.
OTAB-VALUE = V_COMPANY_NAME.
MODIFY OTAB TRANSPORTING VALUE WHERE NAME = 'COMPANY_NAME'.
ENDIF.
SELECT VBPA~ADRNR
ADRC~NAME1
ADRC~NAME2
ADRC~NAME3
ADRC~NAME4
ADRC~CITY1
ADRC~CITY2
ADRC~POST_CODE1
ADRC~STREET
ADRC~REGION
ADRC~TEL_NUMBER
ADRC~MC_STREET
INTO X_ADRC
UP TO 1 ROWS
FROM VBPA JOIN ADRC
ON VBPAADRNR = ADRCADDRNUMBER
WHERE VBELN = V_DEL_NO
AND POSNR = C_000000
AND PARVW = 'WE'.
ENDSELECT.
IF SY-SUBRC = 0 AND X_ADRC-ADRNR NE X_KNA1-ADRNR.
WRITE X_KNA1-ERDAT TO OTAB-VALUE.
MODIFY OTAB TRANSPORTING VALUE WHERE NAME = 'ISS_DT'.
OTAB-VALUE = X_KNA1-KUNNR.
MODIFY OTAB TRANSPORTING VALUE WHERE NAME = 'CUS_NO'.
OTAB-VALUE = X_ADRC-NAME1.
MODIFY OTAB TRANSPORTING VALUE WHERE NAME = 'CUS_NAME'.
endif.
This way the value is passed from the program to the scripts.
Hope this helps.
Regards Rk
Message was edited by:
Rk Pasupuleti
2007 Apr 18 4:44 PM
http://help.sap.com/saphelp_46c/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm
REward and close the threads that are opened by you.
Regards,
Ravi