Application Development and Automation 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: 
Read only

upload Data from excel file into SAP Table

Former Member
0 Likes
2,339

hi @ all,

i want to create a program where i can upload the user-id and location of  employees of large organization  from an excel file and then also the program creates a random password for each employee ,upon executing this program it will provide the user-id  and location (from excel file) and password (generated from program) to another program.

need an early response

Thanks & regards,

Manu Anand

Moderator Message: Requirements dumping - please show your effort & do not expect the forum to spoon-feed you!

Message was edited by: Suhas Saha

1 ACCEPTED SOLUTION
Read only

Rushikesh_Yeole
Contributor
0 Likes
1,153

use Fm SUSR_GENERATE_PASSWORD to generate passwords with parameter X

using GUI_UPLOAD you can achive that

hi @ all,

i want to create a program where i can upload the user-id and location of  employees of large organization  from an excel file and then also the program creates a random password for each employee ,upon executing this program it will provide the user-id  and location (from excel file) and password (generated from program) to another program.

need an early response

Thanks & regards,

Manu Anand

Moderator Message: Requirements dumping - please show your effort & do not expect the forum to spoon-feed you!

Message was edited by: Suhas Saha

4 REPLIES 4
Read only

Former Member
0 Likes
1,153

Hi Manu,

You can get help from below Program.

   REPORT ZBN_UPLOAD.
TABLES:ZMMT_BANK.
TYPE-POOLS: truxs.

PARAMETERS: p_file TYPE  rlgrap-filename.

TYPES: BEGIN OF t_datatab,
       col1(30)    TYPE c,
       col2(30)    TYPE c,
       END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
      wa_datatab type t_datatab.

DATA: it_raw TYPE truxs_t_text_data.

* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      field_name = 'P_FILE'
    IMPORTING
      file_name  = p_file.


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

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR        =
      i_line_header            'X'
      i_tab_raw_data           it_raw       " WORK TABLE
      i_filename               p_file
    TABLES
      i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
   EXCEPTIONS
      conversion_failed        = 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.


***********************************************************************
* END-OF-SELECTION.
END-OF-SELECTION.

  LOOP AT it_datatab INTO wa_datatab.
   ZMMT_BANK-ZBANKL = wa_datatab-col2.
   ZMMT_BANK-BANKA = wa_datatab-col1.
   condense : ZMMT_BANK-ZBANKL , ZMMT_BANK-BANKA.
   MODIFY ZMMT_BANK.
  ENDLOOP.

  IF sy-DBCNT ne 0.
    write: / 'Data Uploaded'.
  ENDIF.

Regards

Abhinav

Read only

Rushikesh_Yeole
Contributor
0 Likes
1,154

use Fm SUSR_GENERATE_PASSWORD to generate passwords with parameter X

using GUI_UPLOAD you can achive that

Read only

Former Member
0 Likes
1,153

You can use 'ALSM_EXCEL_TO_INTERNAL_TABLE'  FM to upload data from xl file, 'SUSR_GENERATE_PASSWORD' will give you the password then download it by 'GUI_DOWNLOAD' FM.

Thanks,

Supratik

Read only

Former Member
0 Likes
1,153

Hi,

You can use SUSR_GENERATE_PASSWORD FM to generate passwords as suggested above and 'F4_FILENAME' and 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM to upload data from excel file to database tables.

Following is the sample code:

*&---------------------------------------------------------------------*

*& Report  ZWEIGHT

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZWEIGHT.

tables: zweight123.

types: begin of ty_weight,

         mandt type mandt,

         pass_no(20) type c,

         date type dats,

         veh_no type zvehno01,

         transporter type ztran,

         material(10) type c,

         mat_type(20) type c,

         weight1 type zweight123-weight1,

         weight2 type zweight123-weight2,

         net_weight type zweight123-net_weight,

         grade type zweight123-grade,

         zunit type zweight123-zunit,

    end of ty_weight.

data: it_data type standard table of ty_weight, "10

       wa_data type ty_weight,

        wa1(4) type c,

        wa2(2) type c,

        wa3(2) type c.

*wa_data-date1 type dats.

*data: it_final type standard table of , "8

*

*         wa_final type zweight123.

data: G_XLDATA LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

DATA: p_file LIKE ibipparms-path.

*Function Module to fetch file from the presentation server

     CALL FUNCTION 'F4_FILENAME'

       EXPORTING

         program_name  = syst-cprog

         dynpro_number = syst-dynnr

         field_name    = 'P_FILE'

       IMPORTING

         file_name     = p_file.

*Function Module to upload excel file data to internal table

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

     EXPORTING

       FILENAME                      = p_file

       I_BEGIN_COL                   = '1'

       I_BEGIN_ROW                   = '7'

       I_END_COL                     = '14'

       I_END_ROW                     = 100

     TABLES

       INTERN                        = G_XLDATA

EXCEPTIONS

      inconsistent_parameters = 1

      upload_ole              = 2

      OTHERS                  = 3.

LOOP AT G_XLDATA.

     CASE G_XLDATA-COL.

       WHEN 2.

         wa_data-pass_no = G_XLDATA-VALUE.

       WHEN 3.

          split g_xldata-value at '.' into wa3 wa2 wa1.

concatenate wa1 wa2 wa3 into wa_data-date." separated by space.

condense wa_data-date no-gaps .

*         wa_data-date = G_XLDATA-VALUE.

       WHEN 4.

         wa_data-veh_no = G_XLDATA-VALUE.

       WHEN 5.

         wa_data-transporter = G_XLDATA-VALUE.

       WHEN 7.

         wa_data-material = G_XLDATA-VALUE.

       WHEN 8.

         wa_data-mat_type = G_XLDATA-VALUE.

       WHEN 10.

         wa_data-weight1 = G_XLDATA-VALUE.

       WHEN 11.

         wa_data-weight2 = G_XLDATA-VALUE.

       WHEN 12.

         wa_data-net_weight = G_XLDATA-VALUE.

       WHEN 14.

         wa_data-grade = G_XLDATA-VALUE.

ENDCASE.

*

*    if wa_data-date is NOT INITIAL.

*

*

**

**split wa_data-date at '.' into wa1 wa2 wa3.

**concatenate wa3 wa2 wa1 into wa_data-date separated by space.

**condense wa_data-date no-gaps .

**wa_data-date1 = wa_data-date.

*endif.

at end of row.

* wa_data-date = wa_data-date1.

*      APPEND wa_data to it_data.

*      modify zweight1234 from table it_data.

modify zweight123 from wa_data.

If sy-subrc eq 0.

  commit work and wait.

   clear wa_data.

  endif.

*      CLEAR wa_data.

endat.

endloop.

*

*modify zweight123 from table it_final.

*

*If sy-subrc eq 0.

*

*     commit work.

*

*     endif.

Regards

Purnand