01-10-2008 9:07 AM
01-10-2008 9:23 AM
Hi,
Just write a simple report.
and use below function modules.
Open_form. -
>Export ur form name
write_form.
close_form.
Regards,
Subbu
01-10-2008 9:28 AM
Hi Pallavi,
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.
*DATA: it_itab TYPE t_tab OCCURS 0 WITH HEADER LINE.
*
*DATA: it_itab1 TYPE t_tab1 OCCURS 0 WITH HEADER LINE.
***********************************************************************
**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 EKORG EKGRP BUKRS AEDAT INTO CORRESPONDING FIELDS OF TABLE it_itab1
*from ekko 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
**********************************************************************
*SELECT SINGLE ekorg ekgrp bukrs
FROM ekko INTO IT_ITAB
WHERE ebeln = s-ebeln.
**SELECT SINGLE *
FROM adrc
WHERE addrnumber = kna1-adrnr AND date_from <= sy-datum
AND date_to >= sy-datum.
*
*CHECK sy-subrc = 0.
*
*******************************************************************
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
reward if useful
suma
01-10-2008 9:33 AM
Hi Pallavi,
The Report where you write open_form, close_form, and write_form is called the print program for that particular script.
Driver program is something which would hold the subroutines declared in the script.
see the below sample code for example:
This is the code written in script
/: IF sales org (condition satisfied).
/: DEFINE &G_STD_TEXT& = ' '
/: PERFORM GET_STANDARD_TEXT IN PROGRAM YTEST
/: CHANGING &G_STD_TEXT&
/: ENDPERFORM
/: INCLUDE &G_STD_TEXT& OBJECT TEXT ID ST LANGUAGE &EKKO-SPRAS&
/: ENDIF.
Now YTEST will be the driver program for the script.
In Driver Program: YTEST (Se38) write the following logic
FORM get_standard_text TABLES tbl_input STRUCTURE itcsy
tbl_output STRUCTURE itcsy.
DATA : l_stdtext(128) TYPE c.
CONSTANTS : c_stdtxt(128) TYPE c VALUE 'ZV_STANDARD_TEXT' .
MOVE c_stdtxt TO l_stdtext.
tbl_output-value = l_stdtext.
MODIFY tbl_output INDEX 1 TRANSPORTING value.
ENDFORM.
Hope this helps you.
Please do reward incase this is useful to you.
Regards,
Farheen
01-10-2008 9:35 AM
Hi pallavi,
print program:
The execution of script is done through an ABAP program, which is referred as Print Program. Each print program should have an ENTRY form , which will be called from customization.
For a standard configuration we can see the form name (script name), print program name and output type in the table TNAPR
The print program uses the Form control functions to call the script.
The print program call either all or some of the form control functions to execute the script
OPEN_FORM (Mandatory) Opens the layout set output
CLOSE_FORM (Mandatory) Ends the layout set output
START_FORM (Optional) Starts a new layout set
WRITE_FORM (Mandatory) Calls a layout set element
END_FORM (Optional) Ends the current layout set
the print program is same as a report except that you can above mentioned function modules.
plz get back to me for further queries.
also plz award if you find it helpful,.
thanks and regards.
Srikanth Tulasi.