Welcome To My BLOG

This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me

Share this link with your friends

http://www.rebtel.com/u/15163104576

For every friend who signs up using this link and makes a payment, we'll give you 8 €!


Tuesday, December 21, 2010

Non-Unicode : Upgrade Obsolete Function Module

1. Obsolete Function Module: WS_UPLOAD.
    Replacement FM:              GUI_UPLOAD.

Note:
  
  1. If the FM ‘WS_UPLOAD' has file type as ASC, then we can use same file    
    type ASC for GUI_UPLOAD also.

 2. But if the FM 'WS_UPLOAD' has file type as DAT, we can not use DAT for  
  'GUI_UPLOAD' as it will give short dump.

    In this case we need use file type as ASC   and
      HAS_FIELD_SEPARATOR = ‘X’.

 3. If the file name or file type of ws_upload have variables or constants   
    Instead of hard coding, then don’t use hard code values for gui_upload.

4. The data type of file name always should be of string type for gui_upload
      The file type should be of Type Character and length 10.

5.  Mention the File type ASC or DAT in Capital letters

6.   If there is any code used by customer inside
     IF SY-SUBRC <> 0 and ENDIF for   ws_upload in 46c version,
     Please use the same code in ECC also after gui_upload.
     If there  is no code inside IF ..ENDIF after FM call then follow
     the same for new  replacement also.

7. If the file name or file type of ws_download have variables or constants   
    Instead of hard coding,then don’t use hard code values for gui_download.
    Declare variables and assign the ws_download variables to new variables  
    and use These in the new FM.

Example:

   Example for File type ASC:

* CALL FUNCTION 'WS_UPLOAD'
*       EXPORTING
*            FILENAME                = P_FILE
*            FILETYPE                = 'ASC'
**      IMPORTING
**           FILELENGTH              =
*       TABLES
*            DATA_TAB                = P_I_DATA
*       EXCEPTIONS
*            CONVERSION_ERROR        = 1
*            FILE_OPEN_ERROR         = 2
*            FILE_READ_ERROR         = 3
*            INVALID_TABLE_WIDTH     = 4
*            INVALID_TYPE            = 5
*            NO_BATCH                = 6
*            UNKNOWN_ERROR           = 7
*            GUI_REFUSE_FILETRANSFER = 8
*            CUSTOMER_ERROR          = 9
*            OTHERS                  = 10.

Replacement FM:

DATA L_P_FILE TYPE STRING.
     L_P_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = L_P_FILE
    FILETYPE                      = ‘ASC’
  TABLES
    DATA_TAB                      = P_I_DATA
 EXCEPTIONS
   FILE_OPEN_ERROR               = 1
   FILE_READ_ERROR               = 2
   NO_BATCH                      = 3
   GUI_REFUSE_FILETRANSFER       = 4
   INVALID_TYPE                  = 5
   NO_AUTHORITY                  = 6
   UNKNOWN_ERROR                 = 7
   BAD_DATA_FORMAT               = 8
   HEADER_NOT_ALLOWED            = 9
   SEPARATOR_NOT_ALLOWED         = 10
   HEADER_TOO_LONG               = 11
   UNKNOWN_DP_ERROR              = 12
   ACCESS_DENIED                 = 13
   DP_OUT_OF_MEMORY              = 14
   DISK_FULL                     = 15
   DP_TIMEOUT                    = 16
   OTHERS                        = 17
          .

  IF SY-SUBRC NE 0.
    MESSAGE E033 WITH P_FILE ' could not be opened'(E03).
  ENDIF.

Example for file type DAT:

* CALL FUNCTION 'WS_UPLOAD'
*       EXPORTING
*            FILENAME                = P_FILE
*            FILETYPE                = 'DAT'
**      IMPORTING
**           FILELENGTH              =
*       TABLES
*            DATA_TAB                = P_I_DATA
*       EXCEPTIONS
*            CONVERSION_ERROR        = 1
*            FILE_OPEN_ERROR         = 2
*            FILE_READ_ERROR         = 3
*            INVALID_TABLE_WIDTH     = 4
*            INVALID_TYPE            = 5
*            NO_BATCH                = 6
*            UNKNOWN_ERROR           = 7
*            GUI_REFUSE_FILETRANSFER = 8
*            CUSTOMER_ERROR          = 9
*            OTHERS                  = 10.
Replacement FM:

DATA L_P_FILE TYPE STRING.
     L_P_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                      = L_P_FILE
    FILETYPE                      = ‘ASC’
    HAS_FIELD_SEPARATOR           = ‘X’
  TABLES
    DATA_TAB                      = P_I_DATA
 EXCEPTIONS
   FILE_OPEN_ERROR               = 1
   FILE_READ_ERROR               = 2
   NO_BATCH                      = 3
   GUI_REFUSE_FILETRANSFER       = 4
   INVALID_TYPE                  = 5
   NO_AUTHORITY                  = 6
   UNKNOWN_ERROR                 = 7
   BAD_DATA_FORMAT               = 8
   HEADER_NOT_ALLOWED            = 9
   SEPARATOR_NOT_ALLOWED         = 10
   HEADER_TOO_LONG               = 11
   UNKNOWN_DP_ERROR              = 12
   ACCESS_DENIED                 = 13
   DP_OUT_OF_MEMORY              = 14
   DISK_FULL                     = 15
   DP_TIMEOUT                    = 16
   OTHERS                        = 17
          .

IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
Else.

2. Obsolete FM       : WS_DOWNLOAD
    Replacement FM: GUI_DOWNLOAD.

Note:
  
  1. If the FM ‘WS_DOWNLOAD' has file type as ASC, then we can use same file    
    Type ASC for GUI_DOWNLOAD also.

 2. If the FM 'WS_DOWNLOAD' has file type as DAT, we can use DAT for  
  'GUI_DOWNLOAD' 

 3. If the file name or file type of ws_download have variables or constants   
    Instead of hard coding,then don’t use hard code values for gui_download.
    Declare variables and assign the ws_download variables to new variables  
    and use These in the new FM.
   
 4. The data type of file name always should be of string type for gui_download
      The file type should be of Type Character and length 10.

5.  Mention the File type ASC or DAT in Capital letters

6.If there is any code used by customer inside IF SY-SUBRC <> 0
and ENDIF for   ws_upload in 46c version, Please use the same code
in ECC also after gui_upload.  If there  is no code inside IF ..ENDIF
after FM call then follow the same for new  replacement also.


Example:

*  CALL FUNCTION 'WS_DOWNLOAD'
*       EXPORTING
*            FILENAME            = P_FILENM
*            FILETYPE            = 'DAT'       " split into records
*       TABLES
*            DATA_TAB            = L_ITAB
*            FIELDNAMES          = T_HEAD
*       EXCEPTIONS
*            FILE_OPEN_ERROR     = 01
*            FILE_WRITE_ERROR    = 02
*            INVALID_FILESIZE    = 03
*            INVALID_TABLE_WIDTH = 04
*            INVALID_TYPE        = 05
*            NO_BATCH            = 06
*            UNKNOWN_ERROR       = 07.

Replacement FM for above FM:

DATA L_P_FILE TYPE STRING.
     L_P_FILE = P_FILENM.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
   FILENAME                        = L_P_FILE
   FILETYPE                        = ‘DAT’
  TABLES
   DATA_TAB                        = L_ITAB
   FIELDNAMES                      = T_HEAD
 EXCEPTIONS
   FILE_WRITE_ERROR                = 1
   NO_BATCH                        = 2
   GUI_REFUSE_FILETRANSFER         = 3
   INVALID_TYPE                    = 4
   NO_AUTHORITY                    = 5
   UNKNOWN_ERROR                   = 6
   HEADER_NOT_ALLOWED              = 7
   SEPARATOR_NOT_ALLOWED           = 8
   FILESIZE_NOT_ALLOWED            = 9
   HEADER_TOO_LONG                 = 10
   DP_ERROR_CREATE                 = 11
   DP_ERROR_SEND                   = 12
   DP_ERROR_WRITE                  = 13
   UNKNOWN_DP_ERROR                = 14
   ACCESS_DENIED                   = 15
   DP_OUT_OF_MEMORY                = 16
   DISK_FULL                       = 17
   DP_TIMEOUT                      = 18
   FILE_NOT_FOUND                  = 19
   DATAPROVIDER_EXCEPTION          = 20
   CONTROL_FLUSH_ERROR             = 21
   OTHERS                          = 22.

3. Obsolete FM: DOWNLOAD

The FM has two functionalities: it provides the F4 functionality to select the input file from the Presentation server and downloads the contents of the internal table from the program to the selected file.

Replacement Method and FM:  

CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG (for selecting the file)
and GUI_DOWNLOAD (download the data into the file)

Example:

*CALL FUNCTION 'DOWNLOAD'
*           EXPORTING
*                FILENAME            = SPACE
*                FILETYPE            = ‘DAT’
*           TABLES
*                DATA_TAB            = T_DOWNL
*           EXCEPTIONS
*                INVALID_FILESIZE    = 1
*                INVALID_TABLE_WIDTH = 2
*                INVALID_TYPE        = 3
*                NO_BATCH            = 4
*                UNKNOWN_ERROR       = 5
*                OTHERS              = 6.
*End of deletion CH01-

Replacement Method for above code:

DATA:  l_deffile     TYPE string,
       l_filen       TYPE string,
       l_path        TYPE string,
       l_fullpath    TYPE string,
       l_filname
       l_usr_act     TYPE I.

l_deffile = SPACE.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
  EXPORTING
    DEFAULT_FILE_NAME    = l_deffile
  CHANGING
    FILENAME             = l_filen
    PATH                 = l_path
    FULLPATH             = l_fullpath
    USER_ACTION          = l_usr_act
  EXCEPTIONS
    CNTL_ERROR           = 1
    ERROR_NO_GUI         = 2
    NOT_SUPPORTED_BY_GUI = 3
    others               = 4.

IF sy-subrc = 0
      AND l_usr_act <>
      CL_GUI_FRONTEND_SERVICES=>ACTION_CANCEL.

l_filename = l_fullpath.

Elseif gv_useract EQ cl_gui_frontend_services=>action_cancel.

L_filename = l_deffile.
      
ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = l_filename
   FILETYPE                          = 'DAT'
  TABLES
    DATA_TAB                        = T_DOWNL
 EXCEPTIONS
   FILE_WRITE_ERROR                = 1
   NO_BATCH                        = 2
   GUI_REFUSE_FILETRANSFER         = 3
   INVALID_TYPE                    = 4
   NO_AUTHORITY                    = 5
   UNKNOWN_ERROR                   = 6
   HEADER_NOT_ALLOWED              = 7
   SEPARATOR_NOT_ALLOWED           = 8
   FILESIZE_NOT_ALLOWED            = 9
   HEADER_TOO_LONG                 = 10
   DP_ERROR_CREATE                 = 11
   DP_ERROR_SEND                   = 12
   DP_ERROR_WRITE                  = 13
   UNKNOWN_DP_ERROR                = 14
   ACCESS_DENIED                   = 15
   DP_OUT_OF_MEMORY                = 16
   DISK_FULL                       = 17
   DP_TIMEOUT                      = 18
   FILE_NOT_FOUND                  = 19
   DATAPROVIDER_EXCEPTION          = 20
   CONTROL_FLUSH_ERROR             = 21
   OTHERS                          = 22.

4. Obsolete FM:  UPLOAD
    Replacement Method and FM:
   
CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG          
                                                                 GUI_UPLOAD

*  CALL FUNCTION 'UPLOAD'
*       EXPORTING
*            FILENAME            = P_FILE
*            FILETYPE            = 'DAT'
*       TABLES
*            DATA_TAB            = W_TAB
*       EXCEPTIONS
*            CONVERSION_ERROR    = 1
*            INVALID_TABLE_WIDTH = 2
*            INVALID_TYPE        = 3
*            NO_BATCH            = 4
*            UNKNOWN_ERROR       = 5
*            OTHERS              = 6.

Replacement method for the above FM:

DATA : I_FILE_TABLE TYPE  TABLE OF FILE_TABLE,
       L_FILETABLE  TYPE  FILE_TABLE,
       l_RC         TYPE  I,
       l_P_DEF_FILE TYPE  STRING
       l_P_FILE     TYPE  STRING,
       l_usr_act    TYPE  I.


  l_P_DEF_FILE = P_FILE.

     CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
       EXPORTING
*         WINDOW_TITLE            =
*         DEFAULT_EXTENSION       =
          DEFAULT_FILENAME        = l_P_DEF_FILE
*         FILE_FILTER             =
*         WITH_ENCODING           =
*         INITIAL_DIRECTORY       =
*         MULTISELECTION          =
       CHANGING
          FILE_TABLE              = I_FILE_TABLE
          RC                      = l_RC
          USER_ACTION             = l_usr_act
*         FILE_ENCODING           =
       EXCEPTIONS
         FILE_OPEN_DIALOG_FAILED = 1
         CNTL_ERROR              = 2
         ERROR_NO_GUI            = 3
         NOT_SUPPORTED_BY_GUI    = 4
         others                  = 5      .

IF sy-subrc = 0
      AND w_usr_act <>
      CL_GUI_FRONTEND_SERVICES=>ACTION_CANCEL.

     LOOP AT I_FILE_TABLE  INTO l_FILETABLE.
        l_P_FILE = l_FILETABLE.
        EXIT.
      ENDLOOP.                                                              

Elseif gv_useract EQ cl_gui_frontend_services=>action_cancel.

L_p_file = l_P_DEF_FILE.

Endif.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = l_P_FILE
      FILETYPE                      = ‘ASC’
      HAS_FIELD_SEPARATOR           = 'X'
    TABLES
      DATA_TAB                      = i_TAB
   EXCEPTIONS
     FILE_OPEN_ERROR               = 1
     FILE_READ_ERROR               = 2
     NO_BATCH                      = 3
     GUI_REFUSE_FILETRANSFER       = 4
     INVALID_TYPE                  = 5
     NO_AUTHORITY                  = 6
     UNKNOWN_ERROR                 = 7
     BAD_DATA_FORMAT               = 8
     HEADER_NOT_ALLOWED            = 9
     SEPARATOR_NOT_ALLOWED         = 10
     HEADER_TOO_LONG               = 11
     UNKNOWN_DP_ERROR              = 12
     ACCESS_DENIED                 = 13
     DP_OUT_OF_MEMORY              = 14
     DISK_FULL                     = 15
     DP_TIMEOUT                    = 16
     OTHERS                        = 17
          .
  IF SY-SUBRC <> 0.
   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

       
5.  Obsolete FM:  WS_FILENAME_GET
      Replacement Method:   file_open_dialog
     If mode is ‘S’, then the replacement method is
                        cl_gui_frontend_services=>file_save_dialog
   If mode is ‘O’, then the replacement method is 
                        cl_gui_frontend_services=> file_open_dialog

Example:


  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            def_filename = lf_dsnam
   *        def_path     = zifbod-pc_path
            mask = ',Month end,Monthend*.xls,All files,*.*.'
            mode         = 'O'
            title        = ' '
       IMPORTING
            filename         = lf_dsnam
*         RC               =
       EXCEPTIONS
            inv_winsys       = 0
            no_batch         = 0
            selection_cancel = 0
            selection_error  = 0
            OTHERS           = 0.

NOTE: We need to use ‘|’ symbol instead of ‘,’ in the FILE_FILTER parameter which is equivalent to MASK.

Replacement method for above FM:

If MODE parameter in WS_FILENAME_GET is specified as O(open) then use the below method CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG.


DATA:lt_files   TYPE filetable,
     l_file     TYPE file_table,
     l_title    TYPE string,
     l_subrc    TYPE i,
     l_usr_act  TYPE i,
     l_def_file TYPE string.

     l_def_file = lf_dsnam.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
  EXPORTING
    WINDOW_TITLE            = ' '
*    DEFAULT_EXTENSION       =
    DEFAULT_FILENAME        = l_def_file
    FILE_FILTER             = 'Month end|Monthend*.xls|All files|*.*'
*    WITH_ENCODING           =
*    INITIAL_DIRECTORY       =
*    MULTISELECTION          =
  CHANGING
    FILE_TABLE              = lt_files
    RC                      = l_subrc
    USER_ACTION             = l_usr_act
*    FILE_ENCODING           =
  EXCEPTIONS
    FILE_OPEN_DIALOG_FAILED = 1
    CNTL_ERROR              = 2
    ERROR_NO_GUI            = 3
    NOT_SUPPORTED_BY_GUI    = 4
    others                  = 5
        .
IF sy-subrc eq 0 AND
   l_usr_act <> CL_GUI_FRONTEND_SERVICES=>ACTION_CANCEL.

   LOOP AT  lt_files INTO l_file.
      MOVE l_file-filename to l_def_file.
      MOVE l_def_file      to lf_dsnam.
      EXIT.
   ENDLOOP.

ENDIF.







6.  Obsolete FM: POPUP_TO_CONFIRM_STEP
     Replacement FM: POPUP_TO_CONFIRM

Example:

 CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption  = 'N'
textline1 = 'Soll das Include überschrieben werden?'(034)
textline2 = i_inc-include
titel     = 'Include existiert bereits!'(039)
* START_COLUMN   = 25
* START_ROW      = 6
* CANCEL_DISPLAY = 'X'
  IMPORTING
  answer = answer
  EXCEPTIONS
  OTHERS = 1.


Replacement Method:

DATA: l_question type string.

Concatenate   'Soll das Include überschrieben werden?'(034)
                       i_inc-include
                       Into
                       l_question.
 
CALL FUNCTION 'POPUP_TO_CONFIRM'
  EXPORTING
 TITLEBAR = 'Include existiert bereits!'(039)
 TEXT_QUESTION = l_question
* TEXT_BUTTON_1 = 'Yes'(020)
* TEXT_BUTTON_2 = 'No'(021)
*ICON_BUTTON_2 = ' '
DEFAULT_BUTTON = '2'
DISPLAY_CANCEL_BUTTON = 'X'
*USERDEFINED_F1_HELP = ' '
*START_COLUMN = 25
*START_ROW = 6
*POPUP_TYPE =
*IV_QUICKINFO_BUTTON_1  = ' '
*IV_QUICKINFO_BUTTON_2 = ' '
 IMPORTING
   ANSWER = answer
* TABLES
*PARAMETER =
 EXCEPTIONS
TEXT_NOT_FOUND = 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.



Note : 
 
   In FM POPUP_TO_CONFIRM_STEP , the value for import parameter ANSWER is

       J (YES),
       N (NO).

But for POPUP_TO_CONFIRM, the value for import parameter ANSWER is

       1 (YES),
       2 (NO).

So, please change these values accordingly while replacing with the new FM.