Friday, 8 February 2013

Generating Transient Program & Persistent Program

*Generating Transient program
DATA itab TYPE TABLE OF string,
             prog TYPE program,
             msg(120TYPE c,
             lin(10TYPE c,
             wrd(10TYPE c,
             off(3TYPE c.

APPEND 'PROGRAM SUBPOOL.'   TO itab.
APPEND 'FORM DYN1.'         TO itab.
APPEND 'WRITE :/ ''I AM A TEMPORARY SUBROUTINE''.' TO itab.
APPEND 'ENDFORM.'           TO itab.

GENERATE SUBROUTINE POOL itab NAME prog MESSAGE msg LINE lin WORD wrd OFFSET off.
*This statement creates a subroutine pool in the main memory area of the running prog
*You pass the source code of the subroutine pool in internal table <itab>.
* The statement returns the name of the generated subroutine pool in field <prog> .
IF sy-subrc <> 0.
WRITE :'ERROR DURING GENERATION OF LINE 'LIN,
             / MSG,
            / 'WORD:'WRD'AT OFFSET :'OFF.
ENDIF.
WRITE :'SUBROUTINE POOL NAME='PROG.
PERFORM dyn1 IN PROGRAM (prog).
_____________________________________________________________________________________
*Generating Persistent Program Programatically
data itab TYPE TABLE OF string.
CONSTANTS rep(40VALUE 'ZDYN_PRO'.
APPEND 'PROGRAM ZDYN_PRO.' TO ITAB.
APPEND 'WRITE :/ '' I AM DYNAMICALLY CREATED ''. ' TO ITAB.
INSERT REPORT REP FROM ITAB.
*above transfers the new executable pgm (ZDYN_PRO)into the program library
SUBMIT (REPAND RETURN.
____________________________________________________________________________________ 

Creating DDIC Structure Dynamically Using FM

***CREATING A DDIC STRUCTURE DYNAMICALLY USING FUNCTION MODULES ***
**PGM CREATES A DDIC STRUCTURE ZSCARR CONTAINING ALL FIELDS OF SCARR TABLE**
DATA lt TYPE TABLE OF dd03p,
       ls TYPE dd02v.
FIELD-SYMBOLS <fs> LIKE LINE OF lt.

CALL FUNCTION 'DDIF_TABL_GET'
  EXPORTING
    name      'SCARR'
  IMPORTING
    dd02v_wa  ls
  TABLES
    dd03p_tab lt.
ls-tabclass 'INTTAB' .
ls-tabname  'ZSCARR' .
ls-as4user  sy-uname .
ls-as4time  sy-uzeit .
ls-as4date  sy-datum .
ls-applclass '' .
ls-authclass '' .
LOOP AT lt ASSIGNING <fs>.
  <fs>-tabname 'ZSCARR'.
ENDLOOP.
CALL FUNCTION 'DDIF_TABL_PUT'
  EXPORTING
    name           = 'ZSCARR'
   dd02v_wa        ls
 TABLES
   dd03p_tab       lt.
IF sy-subrc 0.
  MESSAGE 'STRUCTURE CREATED ' TYPE 'I'.
ENDIF.
CALL FUNCTION 'DDIF_TABL_ACTIVATE'
  EXPORTING
    name 'ZSCARR'.
IF sy-subrc 0.
  MESSAGE 'STRUCTURE ACTIVATED' TYPE 'I'.
ENDIF.

Thursday, 7 February 2013

ABAP System Variables

1. SY-CPAGE - Holds Current Page Number
2. SY-CPROG - Contains Program Name
3. SY-CUCOL - Cursor Position ( Column)
4. SY-CUROW - Cursor Position (Line)
5. SY-DATLO  -  Local Date for User
6. SY-DATUM  - System Date
7. SY-DATUD - Global Date Related To UTC ( GMT )
8. SY-DBCNT - Number of entries read by DB Operation
9. SY-DBNAM- Logical DB for ABAP/4 Program
10. SY-DBSYS -  System DB System
11. SY-DYNNR- Number of Current Screen
12. SY-INDEX -  Number Of Loop passes
13. SY-LANGU- SAP Log on Language Key
14. SY-LILLI  - Number Of Current List Line
15. SY-LINCT - Number Of List Lines
16. SY-LINNO - Current Line for List Creation
17. SY-LINSZ - Line Size of List
18. SY-LISEL - Selected Line For Interactive List
19. SY-LSIND - Number Of Secondary List
20. SY-MANDT - Client Number For SAP Log On
21.SY-MSGID  - Message ID
22. SY-MSGTY - Message Type
23. SY-MSGNO -  Message Number
24. SY-MSGV1 - Message Variable1
25. SY-MSGV2 - Message Variable2
26. SY-MSGV3 - Message Variable3
27. SY-MSGV4 - Message Variable4
28. SY-OPSYS - Operating System
29. SY-PAART -  Print Format
30. SY-PAGCT - Page Size of List in Report Program
31. SY-PAGNO - Current Page in the List
33. SY-PDEST - Print Output Device
34. SY-PFKEY - Run time Current F key Status
35. SY-REPID - Report Name in ABAP
36. SY-SAPRL -  SAP Release
37. SY-SUBRC - Return Value after specific ABAP Statement
38. SY-SYSID - SAP system ID
39. SY-TABIX  -  Current line of Internal Table
40. SY-TCODE - Current Transaction Code
41. SY-TIMLO - Local Time Of User
42. SY-TITLE  - Title of ABAP Program
43. SY-TMAXL - Maximum entries in a Internal Table
44. SY-TNAME  - Name Of Internal Table after first Access
45. SY-UCOMM -Interact : Command field Function entry / Function code
46. SY-ULINE  - Underline
47. SY-UNAME - Session : SAP user from Log On
48. SY-UZEIT  - System Time
49. SY-VLINE  - Vertical Bar

Comments system

Disqus Shortname