SAP R/3

How to converts string number into integer without leading zeroes in ABAP/4

We can apply function module "CONVERSION_EXIT_ALPHA_OUTPUT’ to convert string number to integer without leading zeroes.

Example


  DATA: lv_number TYPE I,
lv_string(10) TYPE C VALUE ’0000000012’.

CALL FUNCTION ’CONVERSION_EXIT_ALPHA_OUTPUT’
  EXPORTING
    INPUT       = lv_string
  IMPORTING
    OUTPUT      = lv_number
          .

How to converts number into string with leading zeroes in ABAP/4

We can apply function module "CONVERSION_EXIT_ALPHA_INPUT’ to convert number into string with leading zeroes.

Example


  DATA: lv_number TYPE I VALUE 12,
lv_string(10) TYPE C.

CALL FUNCTION ’CONVERSION_EXIT_ALPHA_INPUT’
   EXPORTING
     INPUT        = lv_number
   IMPORTING
     OUTPUT       = lv_string
           .

How to read data from application server to internal table in ABAP/4

Normally, when you want to read the file from application server, you will have 5 steps:

  1. Open file in application server by statement:
    OPEN DATASET file_name FOR INPUT IN TEXT MODE.
  2. Checking the file is opened sucessfully by SY-SUBRC = 0
  3. After checking, you can read data from file by statement:
    READ DATASET file_name INTO itab.  
    Note: This statement should be in DO statement
  4. Append data to internal table
  5. Close file by statement:
    CLOSE DATASET file_name

Example

How to transfer data from internal table to application server in ABAP/4

Normally, when you want to transfer data the file to application server, you will
have 3 steps:

  1. Open file in application server by statement:

    OPEN DATASET file_name FOR OUTPUT IN TEXT MODE.
  2. Transfer data from file by statement:

    TRANSFER itab TO file_name. 
    Note: This statement should be in LOOP statement for Internal table
  3. Close file by statement:

CLOSE DATASET file_name.

Example

How to apply function module 'DATE_COMPUTE_DAY' in ABAP/4

The function module "DATE_COMPUTE_DAY" will return the day by 1...7 when you input date. If the date have day:

  • Monday : System will return value = 1
  • Tuesday : System will return value = 2
  • Wednesday : System will return value = 3
  • Thursday : System will return value = 4
  • Friday : System will return value = 5
  • Saturday : System will return value = 6
  • Sunday : System will return value = 7

Example


   CALL FUNCTION ’DATE_COMPUTE_DAY’
     EXPORTING
       date         = l_date1
     IMPORTING
       DAY          = l_day. "Return Value

How to upload PC file to internal table in ABAP/4

When you want to upload PC file to internal table in ABAP/4, you can apply function module "WS_UPLOAD".

Example


call function ’WS_UPLOAD’
      exporting
           filename               = lv_name
           filetype               = lv_type
      tables
           data_tab               = li_tab
      exceptions
           file_open_error        = 1
           file_read_error        = 2
           no_batch               = 3
           gui_refuse_filetransfer = 4
           others                 = 5.