Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Insert records table T087 ( T/C OAVA)

Former Member
0 Kudos

Hi

We need automate a process to insert into T087 table, is there a way to do this?

Thanks in advance,

MGG

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

This is the sample code for your requirement.

Input file should follow the same sequence of T087 as Tab delimed.

POST - 1.


*---------------------------------------------------------------------*
REPORT zjd_int_wty_update_zjdlikp.
*---------------------------------------------------------------------*
DATA : it_T087     TYPE  TABLE OF T087,
       wa_T087     TYPE  T087.

DATA: w_filenm TYPE string,
      w_path TYPE string,
      w_fullpath TYPE string,
      w_filename TYPE string.

DATA: lv_rc         TYPE   i,
      it_tablefiles TYPE   filetable,
      wa_tablefile  TYPE   filename ,
      user_action   TYPE   i,
      lv_filename1  TYPE   string.

*----------------------------------------------------------------------*
* SELECTION SCREEN
*----------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.

PARAMETERS p_tabnam TYPE dd03l-tabname OBLIGATORY DEFAULT 'T087' .
PARAMETERS p_seman LIKE ibipparms-path OBLIGATORY .

SELECTION-SCREEN END OF BLOCK blk1.

*---------------------------------------------------------------------*
*       At selection-screen                                           *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.

  IF p_tabnam NE 'T087'.
    MESSAGE e319(01) WITH 'Enter The Table corectly'.
  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_seman.

  CLEAR : w_filenm, w_path, w_fullpath.
** F4 Button for the File Name Field.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = 'Please specify the file'
      initial_directory       = 'C:\'
    CHANGING
      file_table              = it_tablefiles
      rc                      = lv_rc
      user_action             = user_action
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      OTHERS                  = 4
          .
  IF sy-subrc EQ 0 AND user_action NE
  cl_gui_frontend_services=>action_cancel.

    READ TABLE it_tablefiles INDEX 1 INTO wa_tablefile.

    IF sy-subrc EQ 0.

      lv_filename1 = wa_tablefile.
      p_seman = wa_tablefile.
    ENDIF.

  ENDIF.

See the Next POST-2....

Anil

Edited by: Anil Kumar Reddy on Nov 17, 2009 4:43 PM

6 REPLIES 6

Former Member
0 Kudos

Hello,

This is the sample code for your requirement.

Input file should follow the same sequence of T087 as Tab delimed.

POST - 1.


*---------------------------------------------------------------------*
REPORT zjd_int_wty_update_zjdlikp.
*---------------------------------------------------------------------*
DATA : it_T087     TYPE  TABLE OF T087,
       wa_T087     TYPE  T087.

DATA: w_filenm TYPE string,
      w_path TYPE string,
      w_fullpath TYPE string,
      w_filename TYPE string.

DATA: lv_rc         TYPE   i,
      it_tablefiles TYPE   filetable,
      wa_tablefile  TYPE   filename ,
      user_action   TYPE   i,
      lv_filename1  TYPE   string.

*----------------------------------------------------------------------*
* SELECTION SCREEN
*----------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.

PARAMETERS p_tabnam TYPE dd03l-tabname OBLIGATORY DEFAULT 'T087' .
PARAMETERS p_seman LIKE ibipparms-path OBLIGATORY .

SELECTION-SCREEN END OF BLOCK blk1.

*---------------------------------------------------------------------*
*       At selection-screen                                           *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.

  IF p_tabnam NE 'T087'.
    MESSAGE e319(01) WITH 'Enter The Table corectly'.
  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_seman.

  CLEAR : w_filenm, w_path, w_fullpath.
** F4 Button for the File Name Field.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = 'Please specify the file'
      initial_directory       = 'C:\'
    CHANGING
      file_table              = it_tablefiles
      rc                      = lv_rc
      user_action             = user_action
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      OTHERS                  = 4
          .
  IF sy-subrc EQ 0 AND user_action NE
  cl_gui_frontend_services=>action_cancel.

    READ TABLE it_tablefiles INDEX 1 INTO wa_tablefile.

    IF sy-subrc EQ 0.

      lv_filename1 = wa_tablefile.
      p_seman = wa_tablefile.
    ENDIF.

  ENDIF.

See the Next POST-2....

Anil

Edited by: Anil Kumar Reddy on Nov 17, 2009 4:43 PM

Former Member
0 Kudos

Hi,

POST - 2 .



*----------------------------------------------------------------------*
* START OF SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM download.
  PERFORM update_T087.

*&---------------------------------------------------------------------*
*&      Form  download
*&---------------------------------------------------------------------*
*      To download the extracted data
*----------------------------------------------------------------------*
FORM download.

  CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
            filename                = lv_filename1
            filetype                = 'ASC'
            has_field_separator     = 'X'
       TABLES
            data_tab                = it_T087
       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 e398(00) WITH 'Please check the input file'.
  ENDIF.

ENDFORM.                    " download
*&---------------------------------------------------------------------*
*&      Form  update_likp
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM update_likp.

  IF NOT it_T087 IS INITIAL.
    MODIFY T087 FROM TABLE it_T087.
    COMMIT WORK.
  ENDIF.
  MESSAGE s398(00) WITH 'Talbe has updated successfully'.
ENDFORM.                    " update_T087

Finally execute this program with TAB DELIMETED FILE INPUT..

This will helps your requirement.

Anil.

0 Kudos

Anil - please do not try to get around the 2,500 character limit by splitting your post. Just post the relevant portions of code.

And who owns the code you posted - you or your client?

Rob

0 Kudos

Thanks Anil I will try, check and let you know

0 Kudos

Hai Rob,

This is my test upload program to upload my ZTABLES in my Home Learning PC.

The same logic I given in reply by replacing the ZTABLE to T087.

This is not at all corresponds to my Client.

Anil.

Edited by: Anil Kumar Reddy on Nov 17, 2009 5:13 PM

0 Kudos

OK - the reason I asked is that the policy of the forum is that any code posted has to be the property of the poster.

Rob