Gyan Factory

Gyan Factory
SAP Technical Project Support
Showing posts with label ABAP Data Dictionary. Show all posts
Showing posts with label ABAP Data Dictionary. Show all posts

Tuesday, January 19, 2016

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

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.

Sunday, January 17, 2016

Creating DOMAIN and DATA ELEMENT

CREATING DOMAIN , DATA ELEMENT AND ASSIGNING DOMAIN TO DATA ELEMENT

Creating DOMAIN

Step 1. Go To TCODE- SE11, Select the 'Domain ' radiobutton , provide the Domain name  and 
            Click on the 'CREATE' button.

















=Step 2. Provide the Short Description. Provide the data type as per the requirement and also 
            provide the no of characters. At last click on the activate button to active the DOMAIN.















Creating DATA ELEMENT

Step 1.  Go To TCODE- SE11, Select the Data Type Radio button, Provide the Data Element       
             Name and click on the 'CREATE' Button.













Step 2. Select the Data Element radio button and click on the Tick Button.



 Step 3. Provide the Short Description and select the DATA TYPE Button and Provide the                            DOMAIN Name  and Then Click on the FIELD LABEL Button.
















Step 4. Provide the Field Label text as shown Below and click on the Activate Button to activate the data element.















Summary:  We crated a DOMAIN as per the required data type and length  and created a DATA                      ELEMENT and assigned the DOMAIN  to the DATA ELEMENT. Hence Later we 
                   can use the DATA ELEMENT to assign it to the Field in a Table.

Creating Tables and maintaining the Foreign key relation ship between them

Business Scenario: Suppose we are Maintaining  Employee Details and Every Employee has to be assigned to a Corresponding Department. So the prerequisite is, all the departments should be available first and then when a Employee master data is created, we can assign only the available Department to the Employee.
Table 1 : Department Table (Independent Table/Master Table/Check Table)
Table 2 : Employee Table    (Dependent Table/  Child Table/    Foreign Key Table)

Lets Create the tables with all field details, Create the Table Maintenance Generator, Maintaining the Foreign Key Relationships, Maintaining the Entries and Validating the Entries.
CREATING THE DEPARTMENT TABLE: ZEMP_DEPT

Step 1. Go to TCODE- SE11, Select the Database Table Radio Button and Provide the Table  Name: ZEMP_DEPT and Click on the 'CREATE' Button.























Step 2. Provide the Short Description, Click the 'Delivery and Maintenance' tab. Provide the Delivery Class as 'C' and in the Data Browser/Table View Maint. Select the   Display / Maint allowed. At last click on the Technical Settings Button on the Application tool bar.


















Step 3.  Provide the Data Class 'APPL0' and the Size Category as: '0'. Then Click on the SAVE  button and then click on the BACK button.
























Step 4.  First create all the required Domains and Data Elements as per the required data types     and length so that we can assign the data element against the fields. Provide all the fields and corresponding data elements.Mark MANDT and DEPT_ID as  primary key for this Department table. Finally Click on the Activate Button to activate  the Table.


















Step 5. In order to maintain multiple entries in the table at a time, we need to crate a Table Maintenance Generator (TMG). Click on the Utilities, then click on the Table Maintenance Generator Menu Bar.

















Step 6. First provide the Authorization Object: '&NC&' , then provide the Function Group Name as 'ZEMP_DEPT' (The TMG Function group name normally same as the table name and it is going to hold all the screen logics that is automatically generated when TMG is created). Select Maintenance type as One Step and then click on the button 'Find Scr. number(s)'.























Step 7. Select the First radio button 'Propose Screen number(s)' and click on the Tick Button.






 Step 8.  Automatically the Overview Screen is filled with some value and then click on the 
'CREATE' button to create the TMG as shown on the below diagram.
























Step 9.  At last click on the 'SAVE' button. Save as local Object.























Step 10. If the TMG for the Table is created successfully then a status message is shown as below: 'Request Completed without Errors' and  then click on the back button.




























Step 11. Go to UTILITIES, then TABLE CONTENTS and then click on CREATE ENTRIES.
















Step 12. Click on NEW ENTRIES button.















Step 13. Maintain the DEPT ID and DEPT NAME and  click on the 'SAVE' button and at last click on the BACK button.
















Step 14. Now click on 'UTILITIES', then 'TABLE CONTENTS' and then click on 'DISPLAY'.
















Step 15. Click on the 'EXECUTE' button or else click the F8 button to see all the entries of the table.















Step 16.  Now all the required Departments are available with their DEPT ID AND DEPT NAME.



















_______________________________________________________________________________

CREATING THE EMPLOYEE TABLE: 
Step 1. Go to TCODE- SE11, Select the Database table Radio button and provide the table name                'ZEMPLOYEE' and then click on the CREATE button.


Step 2. Provide the short description, Provide Delivery Class as 'A' and choose 
'Display/Maintenance Allowed'. At last click on the 'TECHNICAL SETTINGS' button.


Step 3. Provide the delivery class as 'APPL0' and the Size Category as '0'. click on SAVE and then click on the BACK button.
Step 4. Create all the domains and data elements as per the requirement. Provide the field names with appropriate data elements. Select the MANDT and the EMP_ID field as the Primary key fields. Maintain the data element 'ZDEPT_ID' against the DEPT field, the same data element as used the the above DEPT table.


Step 5. Now we have to maintain the Foreign key for the DEPT field. So select the particular row and click on the FOREIGN KEY Button.

Step 6.  Provide the check table name ZEMP_DEPT and click on the GENERATE PROPOSAL button.


Step 7. After clicking the Generate Proposal button , system will automatically populates the matching domains between the check table and the foreign key table. Just click on the COPY button.

Step 8. Create the TMG for the table and then create the table entries as per the path shown.

Step 9. click on CREATE ENTRIES button to create Employee Details.
















Step 10. Provide the Employee details and provide the DEPT ID as any id that does not exist in the DEPT table and hit the ENTER button and the system will through the below error message as highlighted below.
























Step 11. So click on the F4 Button and it will show all the possible values from the DEPT table for the field DEPT_ID in the EMPLOYEE TABLE . Choose any one and hit the ENTER button.


















Step 12. Save the Entry by clicking on the SAVE button. Similarly Create other employee details  and SAVE the entries and click on the BACK button.
















Step 13. Click on the highlighted button to see the table entries.


















Step 14. Click on the EXECUTE button or hit F8 key .


















Step 15. Now the employee is only assigned to the departments that are only available in the DEPT table.