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

BDC

Former Member
0 Likes
1,896

Hi ,

      i created a customized table and i try to fill the table using bdc call transaction..For this purpose i created a tcode for that table using table maintenance generator. when i try to upload the excel file it is not uploaded...i checked through it program wise all are correct but i did'nt knew how to rectify. can anybody help me?

20 REPLIES 20
Read only

FredericGirod
Active Contributor
0 Likes
1,865

Hi,

why do you use BDC if it's a specific table ?  BDC is for standard transactions, not for specific.

try the statement INSERT

regards

Fred

Read only

0 Likes
1,865

Hi,

I didnt understand why your using the BDC to update the table and please give me exactly what error ur getting at the time of execution the tcode.

Thanks & Regards

Anoop menon

Read only

0 Likes
1,865

Hi Frederic ,  

   First of all thanks for your reply.. i need to explain my requirment. i have to browse the excel file in system and upload in the customized table  using bdc call transaction method..This is the scenario. hope you understand my scenario..

Read only

0 Likes
1,865

check ur code the rows you mentioned in Excel and code are correct

Read only

0 Likes
1,865

report ZBDC4_TASK

        no standard page heading line-size 255.

TYPES  : BEGIN OF TY_TASK,

          ZLIFNR TYPE ZLIFNR_DE,

           ZBUKRS TYPE ZBUKRS_DE,

           ZLAND1 TYPE ZLAND1_DE,

           ZNAME1 TYPE ZNAME1_DE,

           ZNAME2 TYPE ZNAME2_DE,

           ZORT01 TYPE ZORT01_DE,

           ZORT02 TYPE ZORT02_DE,

           ZPFACH TYPE ZPFACH_DE,

           ZPSTLZ TYPE ZPSTLZ_DE,

           ZREGIO TYPE ZREGIO_DE,

           ZSTRAS TYPE ZSTRAS_DE,

           ZADRNR TYPE ZADRNR_DE,

           ZKTOKK TYPE ZKTOKK_DE,

           ZSPRAS TYPE ZSPRAS_DE,

           ZPHONENO TYPE ZPHONENO_DE,

           ZBANKNAME TYPE ZBANKNAME_DE,

           ZBANKBRCH TYPE ZBANKBRCH_DE,

           ZACCOUNTNO TYPE ZACCOUNT_DE,

        END OF TY_TASK.

DATA : IT TYPE TABLE OF TY_TASK WITH HEADER LINE,

        WA TYPE TY_TASK,

        bdcdata  TYPE TABLE OF bdcdata WITH HEADER LINE,

        it_excel TYPE TABLE OF alsmex_tabline,

        wa_excel TYPE alsmex_tabline,

        ctu      TYPE ctu_params,

        etable   TYPE TABLE OF bdcmsgcoll,

        col      TYPE i.

field-symbols <fs> type any.

parameters pr_file type rlgrap-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PR_FILE.

CALL FUNCTION 'F4_FILENAME'

  EXPORTING

    PROGRAM_NAME        = SYST-CPROG

    DYNPRO_NUMBER       = SYST-DYNNR

*   FIELD_NAME          = ' '

  IMPORTING

    FILE_NAME           = PR_FILE

           .

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

   EXPORTING

     FILENAME                      = PR_FILE

     I_BEGIN_COL                   = 1

     I_BEGIN_ROW                   = 1

     I_END_COL                     = 100

     I_END_ROW                     = 100

   TABLES

     INTERN                        = IT_EXCEL[].

* EXCEPTIONS

*   INCONSISTENT_PARAMETERS       = 1

*   UPLOAD_OLE                    = 2

*   OTHERS                        = 3

           .

START-OF-SELECTION.

LOOP AT it_excel INTO wa_excel.

     col = wa_excel-col.

     ASSIGN COMPONENT col OF STRUCTURE wa TO <fs>.

     <fs> = wa_excel-value.

     AT END OF row.

       IF wa IS NOT INITIAL.

         APPEND wa TO it.

       ENDIF.

       CLEAR wa.

     ENDAT.

     CLEAR col.

     ENDLOOP.

     ctu-dismode = 'N'.

   ctu-updmode = 'A'.

   ctu-defsize = 'X'.

LOOP AT IT INTO WA.

   REFRESH BDCDATA.

perform bdc_dynpro      using 'SAPLZTASK3_PART' '0001'.

perform bdc_field       using 'BDC_CURSOR'

                               'VIM_POSITION_INFO'.

perform bdc_field       using 'BDC_OKCODE'

                               '=NEWL'.

perform bdc_dynpro      using 'SAPLZTASK3_PART' '0002'.

perform bdc_field       using 'BDC_CURSOR'

                               'ZTASK3_PART-ZACCOUNTNO'.

perform bdc_field       using 'BDC_OKCODE'

                               '=SAVE'.

perform bdc_field       using 'ZTASK3_PART-ZLIFNR' WA-ZLIFNR.

*                              '12356'.

perform bdc_field       using 'ZTASK3_PART-ZBUKRS' WA-ZBUKRS.

*                              '2007'.

perform bdc_field       using 'ZTASK3_PART-ZLAND1' WA-ZLAND1.

*                              'US'.

perform bdc_field       using 'ZTASK3_PART-ZNAME1' WA-ZNAME1.

*                              'RAM'.

perform bdc_field       using 'ZTASK3_PART-ZNAME2' WA-ZNAME2.

*                              'MOHAN'.

perform bdc_field       using 'ZTASK3_PART-ZORT01' WA-ZORT01.

*                              'ORISSA'.

perform bdc_field       using 'ZTASK3_PART-ZORT02' WA-ZORT02.

*                              'RANJUR'.

perform bdc_field       using 'ZTASK3_PART-ZPFACH' WA-ZPFACH.

*                              'ORISSA'.

perform bdc_field       using 'ZTASK3_PART-ZPSTLZ' WA-ZPSTLZ.

*                              '154654'.

perform bdc_field       using 'ZTASK3_PART-ZREGIO' WA-ZREGIO.

*                              'NORTH'.

perform bdc_field       using 'ZTASK3_PART-ZSTRAS' WA-ZSTRAS.

*                              '2 GANDHI'.

perform bdc_field       using 'ZTASK3_PART-ZADRNR' WA-ZADRNR.

*                              'VIOLET CAFE'.

perform bdc_field       using 'ZTASK3_PART-ZKTOKK' WA-ZKTOKK.

*                              '4321'.

perform bdc_field       using 'ZTASK3_PART-ZSPRAS' WA-ZSPRAS.

*                              'HI'.

perform bdc_field       using 'ZTASK3_PART-ZPHONENO' WA-ZPHONENO.

*                              '8680909324'.

perform bdc_field       using 'ZTASK3_PART-ZBANKNAME' WA-ZBANKNAME.

*                              'SBI'.

perform bdc_field       using 'ZTASK3_PART-ZBANKBRCH' WA-ZBANKBRCH.

*                              'GUJ'.

perform bdc_field       using 'ZTASK3_PART-ZACCOUNTNO' WA-ZACCOUNTNO.

*                              '85258000011'.


CALL TRANSACTION 'ZTASKK6' USING BDCDATA. " OPTIONS FROM CTU MESSAGES INTO ETABLE.

*----------------------------------------------------------------------*

*        Start new screen                                              *

*----------------------------------------------------------------------*

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

   CLEAR BDCDATA.

   BDCDATA-PROGRAM  = PROGRAM.

   BDCDATA-DYNPRO   = DYNPRO.

   BDCDATA-DYNBEGIN = 'X'.

   APPEND BDCDATA.

ENDFORM.

*----------------------------------------------------------------------*

*        Insert field                                                  *

*----------------------------------------------------------------------*

FORM BDC_FIELD USING FNAM FVAL.

   IF FVAL <> SPACE.

     CLEAR BDCDATA.

     BDCDATA-FNAM = FNAM.

     BDCDATA-FVAL = FVAL.

     APPEND BDCDATA.

   ENDIF.

ENDFORM.

ENDLOOP.

Read only

0 Likes
1,865

Hi anup,

The above is my coding details..tell me where i can made  mistakes.

Read only

0 Likes
1,865

Hi,

In future could you please use better discussion titles, rather than just "BDC" which is pretty meaningless and stops people from finding anything useful in if they are searching on SCN.

Also, as a few others have said, there is absolutely no benefit to use BDC if you are updating a custom table, as you should have complete control over locking it, inserting/updating/deleting records and unlocking it in your own logic.

Thanks,

G.

Read only

0 Likes
1,865

Hi ,

if above is the exact copy of your code,

if you are adding multiple entries then bdc cursor need to be handled.

last perform should be

perform bdc_field    using 'BDC_OKCODE'

                              '=BACK'.

LOOP AT IT INTO WA.

v_index = v_index + 1.

if v_index = max record allowed on screen then

ok code 'P+'

endloop .

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,865

Either use SQL statements, and check data validity (foreign key, domain) in your code or use the FM associated to maintenance dialog (e.g. VIEW_MAINTENANCE_SINGLE_ENTRY, ref : BC Extended Applications Function Library : Extended table maintenance, Call via function module)

Regards,

Raymond

Read only

Former Member
0 Likes
1,865

call this function ' TEXT_CONVERT_XLS_TO_SAP', pass the parameters and it will copy the excel data to internal table then you can use INSERT db-tab FROM TABLE itab

Example:

TYPES truxs_t_text_data(4096) type c occurs 0.

DATA : g_raw_data TYPE TRUXS_T_TEXT_DATA.



CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

       EXPORTING

*   I_FIELD_SEPERATOR          =

        I_LINE_HEADER              = 'X'

         I_TAB_RAW_DATA             = g_raw_data

         I_FILENAME                 = "Excel file path

       TABLES

         I_TAB_CONVERTED_DATA       = itab

* EXCEPTIONS

*   CONVERSION_FAILED          = 1

*   OTHERS                     = 2

               .

   IF SY-SUBRC <> 0.

* Implement suitable error handling here

   ENDIF.

Read only

AnoopMayamkote
Participant
0 Likes
1,865

Field mapping i asked with the excel and the table u ceated tat order is same or not

Read only

0 Likes
1,865

Hi anup,

              mapping is same

Read only

AnoopMayamkote
Participant
0 Likes
1,865

Then Please check the Attributes of the table table maintainace allowed with restriction

Read only

0 Likes
1,865

it is allowed without restriction

Read only

AnoopMayamkote
Participant
0 Likes
1,865

manually thrugh table maintance u can save the data or not please check????

and try to save 2 data manually .

Read only

0 Likes
1,865

no am unable to save the data in table maintenance generator

Read only

former_member201275
Active Contributor
0 Likes
1,865

Have you debugged your program? I would debug and look for where you might be getting subrc ne 0. Also I would debug and stop at the point where your bdc table is completely filled. I would then take this information i.e. what is in the BDC itab and open another session and process the entries step by step with the data and ok-codes as they are in this itab.

Read only

AnoopMayamkote
Participant
0 Likes
1,865

wats the error . its showing..??

Read only

0 Likes
1,865

Hi all, 

i found the solution for that rectified it.. Thanks for all .

Read only

0 Likes
1,865

Please could you post the solution, it would be good to know how you resolved this in case anyone else has similair problem.