Showing posts with label #work area. Show all posts
Showing posts with label #work area. Show all posts

Tuesday, 9 August 2016

Example for Hashed Internal Table

Steps

  • Go to Transaction Code SE38.
  • Enter the program name which start's with Y or Z < program name > and click on CREATE button.
  • Enter the Title.
  • Select the Attribute Type as Executable Program.
  • Click on SAVE button.

Source Code



TYPES BEGIN OF TY_MAKT,
        MATNR TYPE MAKT-MATNR,
        SPRAS TYPE MAKT-SPRAS,
        MAKTX TYPE MAKT-MAKTX,
        END OF TY_MAKT.

DATA WA_MAKT TYPE TY_MAKT,
       IT_MAKT TYPE HASHED TABLE OF TY_MAKT WITH UNIQUE KEY MATNR.


WA_MAKT-MATNR 122.
WA_MAKT-SPRAS 'EN'.
WA_MAKT-MAKTX 'LENOVO'.
INSERT WA_MAKT INTO TABLE IT_MAKT.
CLEAR WA_MAKT.

WA_MAKT-MATNR 123.
WA_MAKT-SPRAS 'EN'.
WA_MAKT-MAKTX 'DELL'.
INSERT WA_MAKT INTO TABLE IT_MAKT.
CLEAR WA_MAKT.


WA_MAKT-MATNR 124.
WA_MAKT-SPRAS 'EN'.
WA_MAKT-MAKTX 'HP'.
INSERT WA_MAKT INTO TABLE IT_MAKT.
CLEAR WA_MAKT.

WA_MAKT-MATNR 122.
WA_MAKT-SPRAS 'DE'.
WA_MAKT-MAKTX 'MICROSOFT'.
INSERT WA_MAKT INTO TABLE IT_MAKT.
CLEAR WA_MAKT.


WA_MAKT-MATNR 124.
WA_MAKT-SPRAS 'EN'.
WA_MAKT-MAKTX 'LENOVO'.
INSERT WA_MAKT INTO TABLE IT_MAKT.
CLEAR WA_MAKT.


LOOP AT IT_MAKT INTO WA_MAKT.

  WRITE / WA_MAKT-MATNR,
            WA_MAKT-SPRAS,
            WA_MAKT-MAKTX.

ENDLOOP.


  • Save -> Check -> Activate.
  • Execute ( F8 ).

Output




Example for Sorted Internal Table- >With Non-Unique Key

Steps

  • Go to Transaction Code SE38.
  • Enter the program name which start's with Y or Z < program name > and click on Create Button.
  • Enter the Title.
  • Select the Attribute Type as Executable Program.
  • Click on SAVE.

Source Code



data it_makt type SORTED  table of makt with NON-UNIQUE key spras
with header line.

select-options s_matnr for it_makt-matnr.

select from makt into table it_makt where matnr in s_matnr.

loop at it_makt .

write / it_makt-matnr it_makt-spras ,it_makt-maktx.

endloop.

  • Save -> Check -> Activate.
  • Execute ( F8 ).

Input

  • Enter the input values.
  • Execute ( F8 ).

Output



Example for Standard Internal Table

Steps

  • Go to Transaction Code SE38.
  • Enter the program name which start's with Y or Z < program name > and click on Create Button.
  • Enter the Title.
  • Select the Attribute Type as Executable Program.
  • Click on SAVE button.

Source Code




data it_makt type standard table of makt with header line.

select-options s_matnr for it_makt-matnr.

select from makt into table it_makt where matnr in s_matnr.

loop at it_makt .

write / it_makt-matnr it_makt-spras ,it_makt-maktx.

endloop.



  • Save-> Check -> Activate.
  • Execute ( F8 ).

Input

  • Enter the input values.
  • Execute ( F8 ).

Output





Different types of Internal Tables based on Sorting Techniques


  1. Standard internal table.
  2. Sorted internal table.
  3. Hashed internal table.

Standard internal table.

  1. By default any internal table is standard internal table.
  2. This is follows linear search(one by one) algorithm.
  3. Searching time is proportional to number of records.
  4. Syntax :
Data : <internal table >  TYPE STANDARD TABLE OF <TB /STR name> WITH NON-UNIQUE KEY  <key > WITH HEADER LINE.

Sorted internal table.

  1. This is follows binary search help.
  2. It supports unique as well as no-unique key.
  3. Syntax :
Data : <internal table >  TYPE SORTED TABLE OF <tab/str name>
            WITH <UNIQUE / non-unique > KEY <keyname>  WITH HEADER LINE .


Hashed internal table.

  1. There is no non-unique key.
  2. Its follows index based search.
  3. Syntax :
Data : <internal table > TYPE HASHED TABLE OF <TB/STR NAME>
             WITH UNIQUE KEY <KEY> WITH HEADER LINE. 

Note : WITH HEADER LINE is optional .

Monday, 8 August 2016

Open Sql Statements

Open Sql

Steps

  • Go to Transaction Code SE11.
  • Create a Table.
   


  • Enter some records.

  • Go to Transaction SE38.
  • Enter the program name which start's with Y or Z < program name > and click on Create.
  • Enter the Title.
  • Select the Attribute Type as Executable Program.
  • Click on SAVE.



Source Code


DATA : WA TYPE ZSD_VBAK.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
  PARAMETERS : VBELN TYPE ZSD_VBAK-SALESORDERNUM.
  SELECTION-SCREEN SKIP 2.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN PUSHBUTTON 15(10) W_TEXT1 USER-COMMAND INS.
    SELECTION-SCREEN PUSHBUTTON 25(10) W_TEXT2 USER-COMMAND DEL.
    SELECTION-SCREEN PUSHBUTTON 35(10) W_TEXT3 USER-COMMAND CLR.
    SELECTION-SCREEN PUSHBUTTON 45(10) W_TEXT4 USER-COMMAND DIS.
    SELECTION-SCREEN PUSHBUTTON 65(10) W_TEXT5 USER-COMMAND UPD.
    SELECTION-SCREEN PUSHBUTTON 79(10) W_TEXT6 USER-COMMAND MOD.
  SELECTION-SCREEN END OF LINE.
  SELECTION-SCREEN SKIP 2.
  PARAMETERS : CDATE TYPE ZSD_VBAK-CREATIONDATE ,
               ETIME TYPE ZSD_VBAK-ENTRYTIME ,
               CREATED TYPE ZSD_VBAK-CREATEDBY,
               NETCURR TYPE ZSD_VBAK-SALESCURR.

SELECTION-SCREEN END OF BLOCK B1.

INITIALIZATION.
W_TEXT1 = 'INSERT'.
W_TEXT2 = 'DELETE'.
W_TEXT3 = 'CLEAR'.
W_TEXT4 = 'DISPLAY'.
W_TEXT5 = 'UPDATE'.
W_TEXT6 = 'MODIFY'.
AT SELECTION-SCREEN.
  CASE SY-UCOMM.
    WHEN 'INS'.
      WA-SALESORDERNUM = VBELN.
      WA-CREATIONDATE = CDATE.
      WA-ENTRYTIME = ETIME.
      WA-CREATEDBY = CREATED.
      WA-SALESCURR = NETCURR.

      INSERT ZSD_VBAK FROM WA.
      IF SY-SUBRC = 4.
        MESSAGE 'RECORD ALREADY EXISTS. PLEASE TRY WITH ANOTHER VBELN' TYPE 'I'.
      ELSEIF SY-SUBRC = 0.
        MESSAGE 'RECORD IS INSERTED' TYPE 'S'.
      ELSE.
        MESSAGE 'RECORD IS NOT INSERTED' TYPE 'I'.

      ENDIF.
   WHEN 'DEL'.
      DELETE FROM ZSD_VBAK WHERE SALESORDERNUM = VBELN.
      IF SY-SUBRC = 4.
        MESSAGE 'RECORD DOESNT EXIST. PLEASE TRY WITH ANOTHER VBELN' TYPE 'I'.
      ELSEIF SY-SUBRC = 0.
        MESSAGE 'RECORD IS DELETED' TYPE 'S'.
      ELSE.
        MESSAGE 'RECORD IS NOT DELETED.' TYPE 'I'.
      ENDIF.
  WHEN 'CLR'.
      CLEAR : VBELN , CDATE , ETIME , CREATED , NETCURR.
  WHEN 'DIS'.
    CLEAR WA.
    SELECT SINGLE * FROM ZSD_VBAK INTO WA WHERE SALESORDERNUM = VBELN.
    IF SY-SUBRC <> 0.
      MESSAGE 'RECORD DOESNT EXIST. PLEASE TRY WITH ANOTHER VBELN' TYPE 'I'.
    ELSE.
      VBELN = WA-SALESORDERNUM.
      CDATE = WA-CREATIONDATE.
      ETIME = WA-ENTRYTIME.
      CREATED = WA-CREATEDBY.
      NETCURR = WA-SALESCURR.
    ENDIF.
  WHEN 'UPD'.
    UPDATE ZSD_VBAK SET: CREATIONDATE = CDATE ENTRYTIME = ETIME CREATEDBY = CREATED SALESCURR = NETCURR
      WHERE SALESORDERNUM = VBELN.
    IF SY-SUBRC = 4.
      MESSAGE 'RECORD DOESNT EXIST. PLEASE TRY WITH ANOTHER VBELN' TYPE 'I'.
    ELSEIF SY-SUBRC = 0.
      MESSAGE 'RECORD UPDATED SUCCESSFULLY.' TYPE 'S'.
    ELSE.
      MESSAGE 'RECORD IS NOT UPDATED.' TYPE 'I'.
    ENDIF.
  WHEN 'MOD'.
      WA-SALESORDERNUM = VBELN.
      WA-CREATIONDATE = CDATE.
      WA-ENTRYTIME = ETIME.
      WA-CREATEDBY = CREATED.
      WA-SALESCURR = NETCURR.
    MODIFY ZSD_VBAK FROM WA.
    IF SY-SUBRC = 0.
        MESSAGE 'RECORD IS MODIFIED' TYPE 'S'.
    ENDIF.
  ENDCASE.




  • Save -> Check -> Activate.
  • Execute ( F8 ).

Input -1

  • Enter the VBELN value  which is  there in table records  and click on Display.

Output

Input -2

  • Click on Clear Button.

Output


Input-3

  • Enter VBELN value which is not there in table records and click  Display Button.

Output

Input-4

  • Enter the input values and click on Insert Button.

Output



Input-5

  • Enter the VBELN value which is there in table records and click on DELETE button.


Output

Input-6

  • Enter the VBELN value which is not  there in table records and click on DELETE button.

Output



Thursday, 14 July 2016

Creating customized select-options

Creating custom select-options

  • Go to transaction code SE11. 
  • Click on Data Type radio button.
  • Enter the standard SELECT-OPTIONS structure name i.e RSDSELOPT.
  • Click on Copy .
  • Pop-up will appear.


  • Customize select-options name and click on continue.

  • Assign the package name , either Local package or Package.
  • Check the status bar.

  • Click on Change button.
  • Pop-up will appear.
  • Click on "Main,in Orginal Lang" .


  • Structure looks like,
  • Choose the Component Type for LOW and HIGH as per requirements and press ENTER.
  • Save -> Check -> Activate.