on 08-07-2008 10:30 PM
Hi Experts,
How to call a driver program in scripts?
thanks
Hi,
You dont call a driver program in script... you execute the script using a driver program
Scripts are not executed independently... you need driver program to run the script.
regards
padma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See this sampal program:
we can call script from 'OPEN_FORM' Fm.
REPORT zm_asset_labels.
************************************************************************
* Print Asset labels
*-----------------------------------------------------------------------
* Jim Hoffman Inverted Sphere Inc. 2003/03/05
************************************************************************
TABLES: itcpo,
anla, "Asset Master Record Segment.....................
anlz. "Time-Dependent Asset Allocations................
SELECT-OPTIONS: s_anln1 FOR anla-anln1,
s_bukrs FOR anla-bukrs,
s_werks FOR anlz-werks.
PARAMETERS: p_form LIKE tnapr-fonam DEFAULT 'Z_LABELS_2_BY_5',
p_ldest LIKE nast-ldest,
p_immed(1) DEFAULT 'X' NO-DISPLAY,
p_delet(1) DEFAULT 'X' NO-DISPLAY,
p_screen AS CHECKBOX.
DATA: xdevice(10),
xdialog.
DATA result LIKE itcpp.
START-OF-SELECTION.
CLEAR: xdialog, xdevice, itcpo.
xdevice = 'PRINTER'.
IF p_ldest EQ space.
xdialog = 'X'.
ELSE.
itcpo-tddest = p_ldest.
ENDIF.
IF p_screen NE space.
itcpo-tdpreview = 'X'.
ENDIF.
itcpo-tdnoprint = 'X'.
itcpo-tdimmed = p_immed.
itcpo-tddelete = p_delet.
itcpo-tdprogram = sy-repid.
itcpo-tdnewid = 'X'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = p_form
language = sy-langu
options = itcpo
device = xdevice
dialog = xdialog
EXCEPTIONS
canceled = 01
device = 02
OTHERS = 03.
IF s_werks-low IS INITIAL.
SELECT * FROM anla WHERE anln1 IN s_anln1
AND bukrs IN s_bukrs
AND xloev = ' '.
SELECT SINGLE * FROM anlz WHERE anln1 = anla-anln1
AND anln2 = anla-anln2
AND bukrs = anla-bukrs
AND bdatu >= sy-datum
AND adatu <= sy-datum.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ASSET'
EXCEPTIONS
OTHERS = 01.
ENDSELECT.
ELSE.
SELECT * FROM anlz WHERE anln1 IN s_anln1
AND bukrs IN s_bukrs
AND werks IN s_werks
AND bdatu >= sy-datum
AND adatu <= sy-datum.
SELECT SINGLE * FROM anla WHERE anln1 = anlz-anln1
AND anln2 = anlz-anln2
AND bukrs = anlz-bukrs.
CHECK anla-xloev IS INITIAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ASSET'
EXCEPTIONS
OTHERS = 01.
ENDSELECT.
ENDIF.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
result = result
EXCEPTIONS
OTHERS = 1.
MESSAGE i000(zz) WITH 'Asset labels processed'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We usually call form using our driver program.During this call all filed that are populated in our driver program are available in the form.
If you want to call a sub-routine pool program using your script, use the following.
Example:
/: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>
/:USING &<field name>&
/:CHANGING &<field name1&
/:ENDPERFORM
Then create subroutine pool program and you have to write the code.
FORM ><subroutine name> tables int_cond structure itcsy
outt_cond structure itcsy.
data : value(20), value1(20). "do your own declarations
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1.
ENDFORM.
Just rough idea given above.
Close the thread once your question is answered.
Regards,
SR
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
In you sapscript :
PERFORM F001_GET_VENDOR IN PROGRAM ZMI_GET_VENDOR_DETAIL
USING &LFA1-ADRNR&
CHANGING &LFA1-STRAS&
CHANGING &LFA1-PFACH&
CHANGING &LFA1-PSTL2&
CHANGING &LFA1-ORT01&
CHANGING &LFA1-ORT02&
CHANGING &LFA1-PSTLZ&
CHANGING &LFA1-LAND1&
CHANGING &LFA1-REGIO&
ENDPERFORM
Create a program with ZMI_GET_VENDOR_DETAIL and in that create a subroutine..
FORM f001_get_vendor TABLES in_par STRUCTURE itcsy
out_par STRUCTURE itcsy.
your stmts.....
ENDFORM.
Regards,
Subramanian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
friend before posting any query please utilize search tab in the forum, u can come across many solutions for ur query.
all the best
The sap scripts and driver program are connected thro the function modules, Open_form,Write_form.
Open_form. -
>Export ur form name
write_form.
close_form.
********
This is a report used for SAP Script which i worked on.Look at it.
******************************************************************
defining tables
******************************************************************
tables: ekko,ekpo,lfa1.
********************************************************************
select options for screen
********************************************************************
select-options: s_ebeln for ekpo-ebeln memory id por.
********************************************************************
creating internal table
********************************************************************
data: begin of it_itab occurs 10,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
matnr type ekpo-matnr,
txz01 type ekpo-txz01,
menge type ekpo-menge,
meins type ekpo-meins,
netpr type ekpo-netpr,
end of it_itab.
data: begin of it_itab1 occurs 10,
aedat type ekko-aedat,
ekorg type ekko-ekorg,
ekgrp type ekko-ekgrp,
bukrs type ekko-bukrs,
end of it_itab1.
***********************************************************************
**SELECTION FOR THE DISPLAY OF MAIN WINDOW
***********************************************************************
select ebeln ebelp matnr txz01 menge meins netpr
into corresponding fields of table it_itab from ekpo
where ebeln in s_ebeln.
select single * into corresponding fields of it_itab1
from ekko where ebeln in s_ebeln .
**********************************************************************
*SELECTION FOR THE DATE
**********************************************************************
SELECT aedat FROM ekko INTO IT_ITAB
WHERE ebeln IN s_ebeln.
ENDSELECT.
**********************************************************************
***SELECTION OF THE header details
**********************************************************************
FROM adrc
WHERE addrnumber = kna1-adrnr AND date_from <= sy-datum
AND date_to >= sy-datum.
*******************************************************************
open form for the script
********************************************************************
call function 'OPEN_FORM'
exporting
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
form = 'ZPO_SCRIPT'
language = sy-langu
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = ''*
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.
******************************************************************
write form for the HEADER OF MAIN window
*******************************************************************
call function 'WRITE_FORM'
exporting
element = 'HEADER '
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 NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
********************************************************************
write form for ITEM DETAILS OF MAIN window
*********************************************************************
loop at it_itab.
call function 'WRITE_FORM'
exporting
element = 'ITEM_DETAILS '
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.
*******************************************************************
write form for DATE window
********************************************************************
call function 'WRITE_FORM'
exporting
element = 'DATE1'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'DATE'
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.
********************************************************************
write form for BARCODE window
*********************************************************************
call function 'WRITE_FORM'
exporting
element = 'BARCODE OF MATNR'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'BARCODE'
IMPORTING
PENDING_LINES = 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.
********************************************************************
write form for PO NUMBER window
*********************************************************************
call function 'WRITE_FORM'
exporting
element = 'PO NO '
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'PO_NUMB'
IMPORTING
PENDING_LINES = 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.
********************************************************************
write form for HEADER window
*********************************************************************
call function 'WRITE_FORM'
exporting
element = 'HEADER DETAILS'
FUNCTION = 'SET'
TYPE = 'BODY'
window = 'HEADER'
IMPORTING
PENDING_LINES = 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.
*******************************************************************
close form for script
********************************************************************
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.
HOPE THIS HELPS U
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 | |
10 | |
7 | |
6 | |
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.