Thursday, July 19, 2012

How To Create a Transparent Table

  1. Enter the table name and press Create
 
  1. Enter the description, Delivery class and check on table maintenance allowed. Then click on the tab Fields.
  1. Enter the ZCHAR in fields tab and ZCHAR_DE in field type tab.
  1. Double click on ZCHAR_DE. Then it will ask for Save. Press ‘YES”.
 
  1. Save it as a local object on pressing Local object button
 
  1. Now it will ask for the creation of the data element. Press Yes.
 
  1. Click on the Field label tab and enter the lengths and descriptions accordingly.
 
  1. Then press Definition tab and enter the domain.
  1. Double click on that zchar_d to create domain, then it will ask for save before going next screen.
Press Yes. 
 
  1. Save it as a local object.






  1. Now it will ask for domain creation. Press Yes.
 
  1. Give short description for that domain which you are creating. And mention the data type in data type  field and length in no. characters field an press ENTER.
  1. Then press Ctrl+F3. It will ask for save before activation. Save it as a local Object.
 
  1. Press Enter.
 
  1. Then the following screen appears. Press on back button.
 
  1. Press Ctrl+F3. You will get the following screen. Press Back button.
 
  1. You will get the following screen.
 
  1. Create one more field ZNUM and give data element name as ZNUM_DE. And double click on ‘ZNUM_DE’
 
  1. Save it by pressing Yes.
 
  1. Now it will ask for the data element creation. Press Yes.
 
  1. Give short description of the data element. And give the lengths and field labels accordingly in Field label tab.
 
  1. Press on Definition tab and give the domain name in Domain field. Double click on ZNUM_D.
 
  1. It will ask for save. Press Yes.
 
  1. Save it as a local Object.

  1. Now it asks for Domain creation. Press Yes.
 
  1. Give short description in short text field. Enter the data type and no. characters, Press Enter.
Then Press on Activate button or Press Ctrl+F3. 
 
  1. Save this as a local object.
  1. Press enter.
 
  1. Now you will get the following screen. Press Back button.
 
  1. Activate the data element By pressing Activate button or Pressing Ctrl+F3.
 
  1. Press enter.
 
  1. Press Back button.


  1. Now we created two fields. And Data elements and Domain for these two fields.
Now we have to maintain the technical settings. Press on Technical settings button.
 
  1. Give the data class and size category of the table as per the requirement.
And press the back button. 
  1. Now activate the table by pressing the activate button or CTRL+F3.
  1. Press enter.
 
  1. Now you will get the following screen.
 
  1. Now enter the data into table. Go to Utilitiesà Table contents à Create Entries.
 
  1. Now enter the data in the fields and Save it.
 
  1. You will get the following screen after clicking the Reset Button.


  1. Enter the data for the second entry into the table.
  2. Save it and press reset.
 
  1. You will get the following screen.
 
44.               Again enter the data for the third entry.
45.                Press save, Reset (Optional) and Back button.
 
46.               Now you will get the following screen.
 
  1. To see the table contents go to Utilities à Table contents à Display. Or press Ctrl+Shift+F10.
 
  1. You will get the following screen.
 
  1. Press on run button or press F8. Now it will display the table contents.

Wednesday, May 2, 2012


DIFFERENCE BERENCE TRANSPARENT, POOL, CLUSTER TABLE :



Transparent
Pool
Cluster
Contain a single table. Used to store master data
They are used to hold a large number of very small tables(stores customizing data or system data)
They are used to hold data from a few number of large tables.(stores system data)
It has a one-to-one relationship with a table in the database
It has a many-to-one relationship with a table in the database
It has a many-to-one relationship with table in the database
For each transparent table there is one associated table in the database
It is stored with other pooled tables in a single table called table pool in the database
Many cluster tables are stored in a single table in the database called a table cluster
The database table has the same name, same number of fields and the fields have the same names
The database table has different name, different number of fields and fields have different names
The database table has different name, different number of fields and fields have different names
There is only a single table
Table pools contain more tables than table clusters
Contains less tables than table pools
Single table can have one or more primary key
Primary key of each table does not begin with same fields or fields
Primary key of each table begins with same fields or fields
Secondary indexes can be created
Secondary indexes cannot be created
Secondary indexes cannot be created
They can be accessed using open and native SQL
They can be accessed using open SQL only
They can be accessed using open  SQL only
USE: They are used to hold master data e.g. Table vendors or table of customers. Example of transaction data is orders placed by customers
USE: They reduce the amount of database resources needed when many small tables have to be opened at the same time
USE: They would be used when the tables have primary key in common and data in these tables are all accesses simultaneously
 

Conversion of SAPSCRIPT to SMARTFORMS


SAP provides a conversion for SAPscript documents to SMARTforms.
This is basically a function module, called FB_MIGRATE_FORM. You can start this function module by hand (via SE37), or create a small ABAP which migrates all SAPscript forms automatically.
You can also do this one-by-one in transaction SMARTFORMS, under
Utilities -> Migrate SAPscript form.
You could also write a small batch program calling transaction SMARTFORMS and running the migration tool.

Wednesday, April 25, 2012

BLOCKED ALV :

Here is a code to implement Blocked ALV display. I hope this code will help u.


*&---------------------------------------------------------------------*
*& Report  ZALV_BLOCKED
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZALV_BLOCKED.

include ZALV_BLOCKED_TOP.
include ZALV_BLOCKED_SEL.
include ZALV_BLOCKED_SUB.

INITIALIZATION.

PERFORM LIST_INIT.

START-OF-SELECTION.

PERFORM FETCH_MARD CHANGING I_MARD.

PERFORM FETCH_MARC USING I_MARD CHANGING I_MARC.

PERFORM FETCH_MARA USING I_MARD CHANGING I_MARA.

PERFORM BUILD_FIELDCAT1 CHANGING I_FIELDCAT.

PERFORM BUILD_FIELDCAT2 CHANGING I_FIELDCAT1.

PERFORM BUILD_FIELDCAT3 CHANGING I_FIELDCAT2.

PERFORM DISPLAY_MARA USING I_MARA.

PERFORM DISPLAY_MARC USING I_MARC.

PERFORM DISPLAY_MARD USING I_MARD.

PERFORM DISPLAY_BLOCK.


TYPE-POOLS : SLIS.

TYPES : BEGIN OF TY_MARA,
        MATNR TYPE MATNR,
        MTART TYPE MTART,
        MBRSH TYPE MBRSH,
        MATKL TYPE MATKL,
        END OF TY_MARA,
      TY_T_MARA TYPE STANDARD TABLE OF TY_MARA,
        BEGIN OF TY_MARC,
          MATNR TYPE MATNR,
          WERKS TYPE WERKS_D,
          EKGRP TYPE EKGRP,
        END OF TY_MARC,
      TY_T_MARC TYPE STANDARD TABLE OF TY_MARC,
        BEGIN OF TY_MARD,
          MATNR TYPE MATNR,
          WERKS TYPE WERKS_D,
          LGORT TYPE LGORT_D,
          LABST TYPE LABST,
        END OF TY_MARD,
      TY_T_MARD TYPE STANDARD TABLE OF TY_MARD.

DATA : I_MARA TYPE TY_T_MARA,
       I_MARC TYPE TY_T_MARC,
       I_MARD TYPE TY_T_MARD.

DATA : GV_MATNR TYPE MATNR.

DATA : I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
       I_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
       I_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV.

DATA: I_EVENTS TYPE SLIS_T_EVENT,
      W_EVENT TYPE SLIS_ALV_EVENT.

DATA : I_LAYOUT TYPE SLIS_LAYOUT_ALV.


*&---------------------------------------------------------------------*
*&  Include           ZALV_BLOCKED_SEL
*&---------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

  SELECT-OPTIONS : S_MATNR FOR GV_MATNR.

SELECTION-SCREEN END OF BLOCK B1.


*&---------------------------------------------------------------------*
*&  Include           ZALV_BLOCKED_SUB
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  FETCH_MARA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_I_MARA  text
*----------------------------------------------------------------------*
FORM FETCH_MARA USING FP_I_MARD TYPE TY_T_MARD
                CHANGING FP_I_MARA TYPE TY_T_MARA.

IF NOT FP_I_MARD IS INITIAL.
SELECT MATNR
       MTART
       MBRSH
       MATKL
  INTO TABLE FP_I_MARA
  FROM MARA
  FOR ALL ENTRIES IN FP_I_MARD
  WHERE MATNR = FP_I_MARD-MATNR.

ENDIF.

ENDFORM. " FETCH_MARA
*&---------------------------------------------------------------------*
*&      Form  FETCH_MARC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_MARA  text
*      <--P_I_MARC  text
*----------------------------------------------------------------------*
FORM FETCH_MARC USING FP_I_MARD TYPE TY_T_MARD
                 CHANGING FP_I_MARC TYPE TY_T_MARC.

  IF NOT FP_I_MARD IS INITIAL.
    SELECT MATNR
           WERKS
           EKGRP
      INTO TABLE FP_I_MARC
      FROM MARC
      FOR ALL ENTRIES IN FP_I_MARD
      WHERE MATNR = FP_I_MARD-MATNR.
  ENDIF.

ENDFORM. " FETCH_MARC
*&---------------------------------------------------------------------*
*&      Form  FETCH_MARD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_I_MARD  text
*      <--P_PERFORM  text
*      <--P_FETCH_MARA  text
*      <--P_I_MARA  text
*----------------------------------------------------------------------*
FORM FETCH_MARD CHANGING FP_I_MARD TYPE TY_T_MARD.

  SELECT MATNR
         WERKS
         LGORT
         LABST
    INTO TABLE FP_I_MARD
    FROM MARD
    WHERE MATNR IN S_MATNR.

ENDFORM. " FETCH_MARD
*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_I_FIELDCAT  text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT1 CHANGING FP_I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

  DATA : W_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

w_fieldcat-col_pos = 1.
w_fieldcat-tabname = 'ty_t_mara'.
w_fieldcat-fieldname = 'MATNR'.
w_fieldcat-seltext_m = 'MATERIAL NUMBER'.

append w_fieldcat to i_fieldcat.
clear w_fieldcat.

w_fieldcat-col_pos = 2.
w_fieldcat-tabname = 'ty_t_final'.
w_fieldcat-fieldname = 'MTART'.
w_fieldcat-seltext_m = 'MATERIAL TYPE'.

append w_fieldcat to i_fieldcat.
clear w_fieldcat.

w_fieldcat-col_pos = 3.
w_fieldcat-tabname = 'ty_t_final'.
w_fieldcat-fieldname = 'MBRSH'.
w_fieldcat-seltext_m = 'INDUSTRY SECTOR'.

append w_fieldcat to i_fieldcat.
clear w_fieldcat.

w_fieldcat-col_pos = 4.
w_fieldcat-tabname = 'ty_t_final'.
w_fieldcat-fieldname = 'MATKL'.
w_fieldcat-seltext_m = 'MATERIAL GROUP'.

append w_fieldcat to i_fieldcat.
clear w_fieldcat.

ENDFORM. " BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCAT2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_I_FIELDCAT1  text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT2 CHANGING FP_I_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.

  DATA : W1_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

w1_fieldcat-tabname = 'ty_t_marc'.
w1_fieldcat-fieldname = 'MATNR'.
w1_fieldcat-seltext_m = 'MATERIAL NUMBER'.

append w1_fieldcat to i_fieldcat1.
clear w1_fieldcat.

w1_fieldcat-tabname = 'ty_t_marc'.
w1_fieldcat-fieldname = 'WERKS'.
w1_fieldcat-seltext_m = 'PLANT'.

append w1_fieldcat to i_fieldcat1.
clear w1_fieldcat.

w1_fieldcat-tabname = 'ty_t_marc'.
w1_fieldcat-fieldname = 'EKGRP'.
w1_fieldcat-seltext_m = 'PURCHASING GROUP'.

append w1_fieldcat to i_fieldcat1.
clear w1_fieldcat.

ENDFORM. " BUILD_FIELDCAT2
*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCAT3
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_I_FIELDCAT2  text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT3 CHANGING FP_I_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV.

  DATA : W2_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

w2_fieldcat-tabname = 'ty_t_mard'.
w2_fieldcat-fieldname = 'MATNR'.
w2_fieldcat-seltext_m = 'MATERIAL NUMBER'.

append w2_fieldcat to i_fieldcat2.
clear w2_fieldcat.

w2_fieldcat-tabname = 'ty_t_mard'.
w2_fieldcat-fieldname = 'WERKS'.
w2_fieldcat-seltext_m = 'PLANT'.

append w2_fieldcat to i_fieldcat2.
clear w2_fieldcat.

w2_fieldcat-tabname = 'ty_t_mard'.
w2_fieldcat-fieldname = 'LGORT'.
w2_fieldcat-seltext_m = 'STORAGE LOCATION'.

append w2_fieldcat to i_fieldcat2.
clear w2_fieldcat.

w2_fieldcat-tabname = 'ty_t_mard'.
w2_fieldcat-fieldname = 'LABST'.
w2_fieldcat-seltext_m = 'VALUATED STOCK'.

append w2_fieldcat to i_fieldcat2.
clear w2_fieldcat.

ENDFORM. " BUILD_FIELDCAT3
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_MARA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_MARA  text
*----------------------------------------------------------------------*
FORM DISPLAY_MARA USING FP_I_MARA TYPE TY_T_MARA.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    IS_LAYOUT                        = I_LAYOUT
    IT_FIELDCAT                      = I_FIELDCAT
    I_TABNAME                        = 'MARA'
    IT_EVENTS                        = I_EVENTS
*   IT_SORT                          =
*   I_TEXT                           = ' '
  TABLES
    T_OUTTAB                         = FP_I_MARA
* EXCEPTIONS
*   PROGRAM_ERROR                    = 1
*   MAXIMUM_OF_APPENDS_REACHED       = 2
*   OTHERS                           = 3
          .
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. " DISPLAY_MARA
*&---------------------------------------------------------------------*
*&      Form  LIST_INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM LIST_INIT .

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    I_CALLBACK_PROGRAM             = SY-REPID
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
          .


ENDFORM. " LIST_INIT
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_MARC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_MARC  text
*----------------------------------------------------------------------*
FORM DISPLAY_MARC USING FP_I_MARC TYPE TY_T_MARC.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      IS_LAYOUT                        = I_LAYOUT
      IT_FIELDCAT                      = I_FIELDCAT1
      I_TABNAME                        = 'MARC'
      IT_EVENTS                        = I_EVENTS
*     IT_SORT                          =
*     I_TEXT                           = ' '
    TABLES
      T_OUTTAB                         = FP_I_MARC
*   EXCEPTIONS
*     PROGRAM_ERROR                    = 1
*     MAXIMUM_OF_APPENDS_REACHED       = 2
*     OTHERS                           = 3
            .
  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. " DISPLAY_MARC
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_MARD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_MARD  text
*----------------------------------------------------------------------*
FORM DISPLAY_MARD USING FP_I_MARD TYPE TY_T_MARD.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    IS_LAYOUT                        = I_LAYOUT
    IT_FIELDCAT                      = I_FIELDCAT2
    I_TABNAME                        = 'MARD'
    IT_EVENTS                        = I_EVENTS
*   IT_SORT                          =
*   I_TEXT                           = ' '
  TABLES
    T_OUTTAB                         = FP_I_MARD
* EXCEPTIONS
*   PROGRAM_ERROR                    = 1
*   MAXIMUM_OF_APPENDS_REACHED       = 2
*   OTHERS                           = 3
          .
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. " DISPLAY_MARD
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_BLOCK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY_BLOCK .

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
*   I_INTERFACE_CHECK             = ' '
*   IS_PRINT                      =
*   I_SCREEN_START_COLUMN         = 0
*   I_SCREEN_START_LINE           = 0
*   I_SCREEN_END_COLUMN           = 0
*   I_SCREEN_END_LINE             = 0
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER       =
*   ES_EXIT_CAUSED_BY_USER        =
* EXCEPTIONS
*   PROGRAM_ERROR                 = 1
*   OTHERS                        = 2
          .
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. " DISPLAY_BLOCK