SAP Com Commu munity nity Network Wiki Wiki - ABAP ABAP Development Development - My My first SAP SAP Scri...
L og og I n
http://wiki.sdn.sap.com http://wiki.sdn.sap.com/wiki/display/ABA /wiki/display/ABAP/My P/My+first+ +first+SAP+ SAP+Script+st Script+step... ep...
Re gi gist er er
A bo bou t Us
Ho ow w to Co nt nt ri rib ut ute Welcome Guest
SDN C om om mu mu ni ni ty ty Home
Forums
Wiki
Blogs
BP X C om omm un un iitt y Ar ttiicles
eLearning
Bu si sin es essO bj bj ec ec ts ts Downl oa oads
My first SAP Script step by step Added by Krishna Chauhan, last edited by Krishna Chauhan on Jan 13, 2009
Un iiv ver si sit y Allia nc nc es es
Code Exchange
Career Center
SA P Ec oH oH ub ub Events
InnoCentive
Idea Place
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
Code in SE38: *&---------------------------------------------------------------------* *& Report YKC_SCRIPT_DRIVER_PRO *& *&---------------------------------------------------------------------* *&Krishna Chauhan (Sparta Consulting) *&Date: 09 Jan 2009 *&---------------------------------------------------------------------* REPORT YKC_SCRIPT_DRIVER_PRO. tables: mara, makt, marc,mard. data: begin of it_final occurs 0, matnr like mara-matnr, maktx like makt-maktx, ersda like mara-ersda, ernam like mara-ernam, werks like mard-werks, lgort like mard-lgort, beskz like marc-beskz, dismm like marc-dismm, end of it_final. *---internal table to get data from mara data: begin of it_mara occurs 0, matnr like mara-matnr, ersda like mara-ersda, ernam like mara-ernam, end of it_mara. *---internal table to store mat description data: begin of it_makt occurs 0, matnr like makt-matnr, spras like makt-spras, maktx like makt-maktx, end of it_makt. *--internal table to keep data from marc data: begin of it_marc occurs 0, matnr like mara-matnr, werks like marc-werks, beskz like marc-beskz, dismm like marc-dismm, end of it_marc. *--internal table to keep data from mard data: begin of it_mard occurs 0, matnr like mara-matnr, werks like mard-werks, lgort like mard-lgort, end of it_mard. Select-options s_matnr for mara-matnr. Start-of-selection. perform get_data. PERFORM open_form. LOOP AT it_final. PERFORM start_form. PERFORM write_form. PERFORM end_form.
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
ENDLOOP. PERFORM close-form. *&---------------------------------------------------------------------* *&
Form GET_DA TA
*&---------------------------------------------------------------------* *
text: Getting data into final internal table for display
*----------------------------------------------------------------------* form GET_DATA . select matnr ersda ernam from mara into table it_mara where matnr in s_matnr. sort it_mara by matnr. if not it_mara[] is initial. *---getting common data from mara & marc on the basis of matnr. select matnr werks beskz dismm from marc into table it_marc for all entries in it_mara where matnr = it_mara-matnr. select matnr spras maktx from makt into table it_makt for all entries in it_mara where matnr = it_mara-matnr and spras = 'E'. endif. *---gettng common data from marc & mard on the basis of matnr & werks. sort it_marc by matnr werks. if not it_marc[] is initial. select matnr werks lgort from mard into table it_mard for all entries in it_marc where matnr = it_marc-matnr and werks = it_marc- werks. endif. sort it_mard by matnr werks. loop at it_mard. read table it_mara with key matnr = it_mard-matnr binary search. if sy-subrc = 0. *---getting matnr, ersda, ernam into it-final it_final-matnr = it_mara-matnr. it_final-ersda = it_mara-ersda. it_final-ernam = it_mara-ernam. endif. *---getting material desc read table it_makt with key matnr = it_mard-matnr binary search. if sy-subrc = 0. it_final-maktx = it_makt-maktx. endif. *---getting werks, lgort, beskz, dismm into it_final it_final-werks = it_mard-werks. it_final-lgort = it_mard-lgort. read table it_marc with key matnr = it_mard-matnr werks = it_mard-werks binary search. if sy-subrc = 0. it_final-beskz = it_marc-beskz. it_final-dismm = it_marc-dismm. endif. append it_final. clear it_final. endloop. endform.
" GET_DA TA
*&---------------------------------------------------------------------* *&
Form OPEN-FORM
*&---------------------------------------------------------------------* *
text: opening script form
*----------------------------------------------------------------------* Form OPEN_FORM . CALL FUNCTION 'OPEN_FORM' EXPORTING Form = 'YKC_FIRST_SCRIPT'. Endform.
"OPEN-FORM
*&---------------------------------------------------------------------* *&
Form START_ FORM
*&---------------------------------------------------------------------* *
Text: Starting form
*----------------------------------------------------------------------*
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
Form START_FORM . CALL FUNCTION 'START_FORM' EXPORTING Form = 'YKC_FIRST_SCRIPT'. Endform.
"START_FORM
*&---------------------------------------------------------------------* *&
Form WRITE_FORM
*&---------------------------------------------------------------------* *
text: Writing into form
*----------------------------------------------------------------------* Form WRITE_FORM . *--CALL FUNCTION 'WRITE_FORM' EXPORTING Window = 'GRAPH1'. CALL FUNCTION 'WRITE_FORM' EXPORTING Element
= 'E1'
* FUNCTION
= 'SET'
* TYPE
= 'BODY'
Window
= 'WINDOW1'
. CALL FUNCTION 'WRITE_FORM' EXPORTING element
= 'E2'
* FUNCTION
= 'SET'
* TYPE
= 'BODY'
Window
= 'MAIN'
. endform.
" WRITE_FORM
*&---------------------------------------------------------------------* *&
Form END_FORM
*&---------------------------------------------------------------------* *
text: Ending form
*----------------------------------------------------------------------* form END_FORM . CALL FUNCTION 'END_FORM' * IMPORTING * RESULT
=
* EXCEPTIONS * UNOPENED
=1
* BAD_PAGEFORMAT_FOR_PRINT * SPOOL_ERROR
=2
=3
* OTHERS
=4
. 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.
" END_FOR M
*&---------------------------------------------------------------------* *&
Form CLOSE-FORM
*&---------------------------------------------------------------------* *
text
*----------------------------------------------------------------------* form CLOSE-FORM . CALL FUNCTION 'CLOSE_FORM' * IMPORTING * RESULT * RDI_RESULT
= =
* TABLES * OTFDATA
=
* EXCEPTIONS * UNOPENED
=1
* BAD_PAGEFORMAT_FOR_PRINT * SEND_ERROR * SPOOL_ERROR * OTHERS
=3 =4 =5
. endform. The output will be:
"CLOSE-FORM
=2
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...
SAP Community Network Wiki - ABAP Development - My first SAP Scri...
Labels tutorial abap
Contact Us Site Index Marketing Opportunities Powered by SAP NetWeaver
Legal Terms
Privacy
Impressum
http://wiki.sdn.sap.com/wiki/display/ABAP/My+first+SAP+Script+step...