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: 

Data uploading through MOdule pool

Former Member
0 Kudos

Hi Guys,

I have a requirement in module pool.

I have to create a table contol with 2 buttons 1>upload 2> save.

Now when i click on the upload button i can able to access a local file and when select that local file all the data should display on the table control.

After that when i click on the save button the whole data should update in the table.

Upto now i have created the Table control and able to access the local file by using F4_FILENAME(FM) in the PAI. Now when i select the local file the the program is going to exit.

Can anyone put some idea on this.

Thanks,

Baidyanath

1 ACCEPTED SOLUTION

I355602
Advisor
Advisor
0 Kudos

Hi,

Check in the attributes of the screen, the value in the next screen.

Give this value as the same screen number you are currently working on.

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

4 REPLIES 4

I355602
Advisor
Advisor
0 Kudos

Hi,

After taking the file from the system using F4_FILENAME, use FM GUI_UPLOAD to populate an internal table of same structure as you have records in the flat file.

Make a text file with all the records.

Fields separated by tabs and one record in one line.

save this file as .txt and use this file when using F4_FILENAME


  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                     = 'c:\file.txt' "file path/use parameter value here
     FILETYPE                      = 'DAT'
*     HAS_FIELD_SEPARATOR           = ' '
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = 'X'
*     DAT_MODE                      = ' '
*     CODEPAGE                      = ' '
*     IGNORE_CERR                   = ABAP_TRUE
*     REPLACEMENT                   = '#'
*     CHECK_BOM                     = ' '
*     VIRUS_SCAN_PROFILE            =
*     NO_AUTH_CHECK                 = ' '
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
    TABLES
      DATA_TAB                      = it_ekpo
* 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.

Now in PBO, read this internal table into the table control, and your table control will be populated with the flat file records.

At screen logic:-


PROCESS BEFORE OUTPUT.
  MODULE status_8002.

  LOOP WITH CONTROL po_tab. "po_tab is table control
    MODULE pass_data. "pass data to table control form internal table
  ENDLOOP.

PROCESS AFTER INPUT.
  MODULE user_command_8002. "say you get file name here and upload your internal table

  LOOP WITH CONTROL po_tab.
  ENDLOOP.

PBO,


*&---------------------------------------------------------------------*
*&      Module  PASS_DATA  OUTPUT
*&---------------------------------------------------------------------*
MODULE pass_data OUTPUT.
  READ TABLE it_ekpo into wa_ekpo INDEX po_tab-current_line.
ENDMODULE.                 " PASS_DATA  OUTPUT

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Edited by: Tarun Gambhir on Jan 16, 2009 12:27 PM

Former Member
0 Kudos

Hi Tarun,

I have done like this.

But when i check in the debugging mode.....After the PAI(When the internal table is filled with excel file), program goes out of the module (module user_command_0100) and exit.

Here u can see my code

process before output.
 module status_0100.
   loop  with control tc100.
     module display_data.
   endloop.

process after input.
   module user_command_0100.
   loop  with control tc100.
   endloop. 

PBO......

module display_data output.

  READ TABLE t_upload into wa_t_upload INDEX TC100-current_line.

endmodule.                 " display_data  OUTPUT 

PAI.......

CASE ok_code.
    WHEN  'UPD'.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = file1.


      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = file1
          i_begin_col             = 1
          i_begin_row             = 1
          i_end_col               = 13
          i_end_row               = 10000
        TABLES
          intern                  = itab1
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.

      ENDIF..
     ENDCASE.

Please check this.....

Thanks,

Baidyanath

I355602
Advisor
Advisor
0 Kudos

Hi,

Check in the attributes of the screen, the value in the next screen.

Give this value as the same screen number you are currently working on.

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Former Member
0 Kudos

Hi Tarun,

Thanks for ue reply.

Now i have changed the screen attributes .

but still the problem continues....

Do u think my code is correct?

thanks,

Baidyanath