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 problem with BDCRECX1

f_cemunal
Participant
0 Likes
1,570

hello,

i am trying to modify a sap document with uploading a txt file.the program has BDCRECX1 as include and while serching i have had some information about BDCRECX1 but stil i dont know what to do.

what am i suppossed to do with BDCRECX1 selection screen?

hello,

i am trying to modify a sap document with uploading a txt file.the program has BDCRECX1 as include and while serching i have had some information about BDCRECX1 but stil i dont know what to do.

what am i suppossed to do with BDCRECX1 selection screen?

12 REPLIES 12
Read only

f_cemunal
Participant
0 Likes
1,529

any ideas?

Read only

0 Likes
1,529

Hi ,

       You can copy BDCRECX1 into z include and modify it as per your requirements,

selection-screen begin of block b1 with frame.
parameter:p_infile like rlgrap-filename obligatory.
selection-screen:skip.

parameter: smalllog as checkbox.
selection-screen end  of block b1.
include zbdcrecx.



inside the zbdcrecx you have to do some modification as per your requirements .




Regards,

      Thangam.P

Read only

0 Likes
1,529

hi,

thank you for your answer.

here is my code


report ZRTB0007

        no standard page heading line-size 255.

include bdcrecx1.

parameters: dataset(132) lower case,

             p_karak(10).

data: begin of record occurs 100,

         MATKL(009),

         WGBEZ(060),

       end of record.

*** End generated data section ***

start-of-selection.

   CALL FUNCTION 'UPLOAD'

     EXPORTING

       FILENAME = 'c:\malgrubu.txt'

       FILETYPE = 'DAT'

     TABLES

       DATA_TAB = record.

   perform open_group.

   if not p_karak is initial.

     loop at record.

       perform bdc_dynpro      using 'SAPMWWG2' '4000'.

       perform bdc_field       using 'BDC_OKCODE' '=CLWB'.

       perform bdc_field       using 'T023D-MATKL' record-MATKL.

       perform bdc_dynpro      using 'SAPLCLMO' '7777'.

       perform bdc_field       using 'BDC_OKCODE' '=MERK'.

       perform bdc_dynpro      using 'SAPLCLMO' '7777'.

       perform bdc_field       using 'BDC_OKCODE' '=SAVE'.

       perform bdc_field       using 'RMCLM-MERKMA(01)' p_karak.

       perform bdc_field       using 'RMCLM-RELEV(01)' '2'.

       perform bdc_dynpro      using 'SAPLCLMO' '7777'.

       perform bdc_field       using 'BDC_OKCODE' '/EABBR'.

       perform bdc_transaction using 'WG22'.

     endloop.

   else.

     loop at record.

       perform bdc_dynpro      using 'SAPMWWG2' '1000'.

       perform bdc_field       using 'BDC_OKCODE' '/00'.

       perform bdc_field       using 'T023D-MATKL' record-MATKL.

       perform bdc_field       using 'WWGD-CLASS1' record-MATKL(7).

       perform bdc_dynpro      using 'SAPMWWG2' '1100'.

       perform bdc_field       using 'BDC_OKCODE' '=SAVE'.

       perform bdc_field       using 'T023TD-WGBEZ' record-WGBEZ(20).

       perform bdc_field       using 'T023TD-WGBEZ60' record-WGBEZ.

       perform bdc_field       using 'WWGD-CLASS1' record-MATKL(7).

       perform bdc_field       using 'T023D-SPART' '10'.

       perform bdc_transaction using 'WG21'.

     endloop.

     loop at record.

       perform bdc_dynpro      using 'SAPMWWG2' '4000'.

       perform bdc_field       using 'BDC_OKCODE' '/00'.

       perform bdc_field       using 'T023D-MATKL' record-MATKL.

       perform bdc_dynpro      using 'SAPMWWG2' '1100'.

       perform bdc_field       using 'BDC_OKCODE' '=SAVE'.

       perform bdc_field       using 'WWGD-CLASS1' record-MATKL(7).

       perform bdc_transaction using 'WG22'.

     endloop.

   endif.

   perform close_group.

i have to use this program but i dont know what to write in selection screen.

Read only

0 Likes
1,529

please provide coding of program bdcrecx1

Regards,

   Thanagm.P

Read only

0 Likes
1,529

here it is :


***INCLUDE BDCRECX1.

*  for programs doing a data transfer by creating a batch-input session

*  and

*  for programs doing a data transfer by CALL TRANSACTION USING

SELECTION-SCREEN BEGIN OF LINE.

   PARAMETERS SESSION RADIOBUTTON GROUP CTU.  "create session

   SELECTION-SCREEN COMMENT 3(20) TEXT-S07 FOR FIELD SESSION.

   selection-screen position 45.

   PARAMETERS CTU RADIOBUTTON GROUP  CTU.     "call transaction

   SELECTION-SCREEN COMMENT 48(20) TEXT-S08 FOR FIELD CTU.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 3(20) TEXT-S01 FOR FIELD GROUP.

   selection-screen position 25.

   PARAMETERS GROUP(12).                      "group name of session

   SELECTION-SCREEN COMMENT 48(20) TEXT-S05 FOR FIELD CTUMODE.

   selection-screen position 70.

   PARAMETERS CTUMODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.

                                       "A: show all dynpros

                                       "E: show dynpro on error only

                                       "N: do not display dynpro

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 3(20) TEXT-S02 FOR FIELD USER.

   selection-screen position 25.

   PARAMETERS: USER(12) DEFAULT SY-UNAME.     "user for session in batch

   SELECTION-SCREEN COMMENT 48(20) TEXT-S06 FOR FIELD CUPDATE.

   selection-screen position 70.

   PARAMETERS CUPDATE LIKE CTU_PARAMS-UPDMODE DEFAULT 'L'.

                                       "S: synchronously

                                       "A: asynchronously

                                       "L: local

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 3(20) TEXT-S03 FOR FIELD KEEP.

   selection-screen position 25.

   PARAMETERS: KEEP AS CHECKBOX.       "' ' = delete session if finished

                                       "'X' = keep   session if finished

   SELECTION-SCREEN COMMENT 48(20) TEXT-S09 FOR FIELD E_GROUP.

   selection-screen position 70.

   parameters E_GROUP(12).             "group name of error-session

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 3(20) TEXT-S04 FOR FIELD HOLDDATE.

   selection-screen position 25.

   PARAMETERS: HOLDDATE LIKE SY-DATUM.

   SELECTION-SCREEN COMMENT 51(17) TEXT-S02 FOR FIELD E_USER.

   selection-screen position 70.

   PARAMETERS: E_USER(12) DEFAULT SY-UNAME.    "user for error-session

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 51(17) TEXT-S03 FOR FIELD E_KEEP.

   selection-screen position 70.

   PARAMETERS: E_KEEP AS CHECKBOX.     "' ' = delete session if finished

                                       "'X' = keep   session if finished

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 51(17) TEXT-S04 FOR FIELD E_HDATE.

   selection-screen position 70.

   PARAMETERS: E_HDATE LIKE SY-DATUM.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 1(33) TEXT-S10 FOR FIELD NODATA.

   PARAMETERS: NODATA DEFAULT '/' LOWER CASE.          "nodata

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

   SELECTION-SCREEN COMMENT 1(33) TEXT-S11 FOR FIELD SMALLLOG.

   PARAMETERS: SMALLLOG as checkbox.  "' ' = log all transactions

                                      "'X' = no transaction logging

SELECTION-SCREEN END OF LINE.

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

*   data definition

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

*       Batchinputdata of single transaction

DATA:   BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.

*       messages of call transaction

DATA:   MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

*       error session opened (' ' or 'X')

DATA:   E_GROUP_OPENED.

*       message texts

TABLES: T100.

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

*   at selection screen                                                *

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

AT SELECTION-SCREEN.

* group and user must be filled for create session

   IF SESSION = 'X' AND

      GROUP = SPACE OR USER = SPACE.

     MESSAGE E613(MS).

   ENDIF.

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

*   open dataset                                                       *

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

FORM OPEN_DATASET USING P_DATASET.

   OPEN DATASET P_DATASET

                FOR INPUT IN TEXT MODE

                ENCODING DEFAULT.

   IF SY-SUBRC <> 0.

     WRITE: / TEXT-E00, SY-SUBRC.

     STOP.

   ENDIF.

ENDFORM.

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

*   close dataset                                                      *

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

FORM CLOSE_DATASET USING P_DATASET.

   CLOSE DATASET P_DATASET.

ENDFORM.

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

*   create batchinput session                                          *

*   (not for call transaction using...)                                *

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

FORM OPEN_GROUP.

   IF SESSION = 'X'.

     SKIP.

     WRITE: /(20) 'Create group'(I01), GROUP.

     SKIP.

*   open batchinput group

     CALL FUNCTION 'BDC_OPEN_GROUP'

          EXPORTING  CLIENT   = SY-MANDT

                     GROUP    = GROUP

                     USER     = USER

                     KEEP     = KEEP

                     HOLDDATE = HOLDDATE.

     WRITE: /(30) 'BDC_OPEN_GROUP'(I02),

             (12) 'returncode:'(I05),

                  SY-SUBRC.

   ENDIF.

ENDFORM.

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

*   end batchinput session                                             *

*   (call transaction using...: error session)                         *

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

FORM CLOSE_GROUP.

   IF SESSION = 'X'.

*   close batchinput group

     CALL FUNCTION 'BDC_CLOSE_GROUP'.

     WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),

             (12) 'returncode:'(I05),

                  SY-SUBRC.

   ELSE.

     IF E_GROUP_OPENED = 'X'.

       CALL FUNCTION 'BDC_CLOSE_GROUP'.

       WRITE: /.

       WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).

       E_GROUP_OPENED = ' '.

     ENDIF.

   ENDIF.

ENDFORM.

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

*        Start new transaction according to parameters                 *

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

FORM BDC_TRANSACTION USING TCODE.

   DATA: L_MSTRING(480).

   DATA: L_SUBRC LIKE SY-SUBRC.

* batch input session

   IF SESSION = 'X'.

     CALL FUNCTION 'BDC_INSERT'

          EXPORTING TCODE     = TCODE

          TABLES    DYNPROTAB = BDCDATA.

     IF SMALLLOG <> 'X'.

       WRITE: / 'BDC_INSERT'(I03),

                TCODE,

                'returncode:'(I05),

                SY-SUBRC,

                'RECORD:',

                SY-INDEX.

     ENDIF.

* call transaction using

   ELSE.

     REFRESH MESSTAB.

     CALL TRANSACTION TCODE USING BDCDATA

                      MODE   CTUMODE

                      UPDATE CUPDATE

                      MESSAGES INTO MESSTAB.

     L_SUBRC = SY-SUBRC.

     IF SMALLLOG <> 'X'.

       WRITE: / 'CALL_TRANSACTION',

                TCODE,

                'returncode:'(I05),

                L_SUBRC,

                'RECORD:',

                SY-INDEX.

       LOOP AT MESSTAB.

         SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA

                                   AND   ARBGB = MESSTAB-MSGID

                                   AND   MSGNR = MESSTAB-MSGNR.

         IF SY-SUBRC = 0.

           L_MSTRING = T100-TEXT.

           IF L_MSTRING CS '&1'.

             REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.

             REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.

             REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.

             REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.

           ELSE.

             REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.

             REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.

             REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.

             REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.

           ENDIF.

           CONDENSE L_MSTRING.

           WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).

         ELSE.

           WRITE: / MESSTAB.

         ENDIF.

       ENDLOOP.

       SKIP.

     ENDIF.

** Erzeugen fehlermappe ************************************************

     IF L_SUBRC <> 0 AND E_GROUP <> SPACE.

       IF E_GROUP_OPENED = ' '.

         CALL FUNCTION 'BDC_OPEN_GROUP'

              EXPORTING  CLIENT   = SY-MANDT

                         GROUP    = E_GROUP

                         USER     = E_USER

                         KEEP     = E_KEEP

                         HOLDDATE = E_HDATE.

          E_GROUP_OPENED = 'X'.

       ENDIF.

       CALL FUNCTION 'BDC_INSERT'

            EXPORTING TCODE     = TCODE

            TABLES    DYNPROTAB = BDCDATA.

     ENDIF.

   ENDIF.

   REFRESH BDCDATA.

ENDFORM.

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

*        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 <> NODATA.

     CLEAR BDCDATA.

     BDCDATA-FNAM = FNAM.

     BDCDATA-FVAL = FVAL.

     APPEND BDCDATA.

   ENDIF.

ENDFORM.

Read only

0 Likes
1,529

Hi Cem,

             thanks for your reply..  actually what you want to change in your uploading program.

Regards,

   Thangam.P

Read only

0 Likes
1,529

hi thangam,

this program is made by someone else.now i need to modify from excel file but unfourtunately i dont know how to use this program.

i would be grateful if you helped me because i dont have to look it up and learn.

regards.

cem.

Read only

0 Likes
1,529

Cem,

          Have you checked.?

Read only

thangam_perumal
Contributor
0 Likes
1,529

Hi Ok Cem,

                  Please prepare your excel format as per your requirements.

data: itab1 like alsmex_tabline occurs 0 with header line.

selection-screen begin of block b1 with frame.
parameter:p_infile like rlgrap-filename obligatory.

selection-screen end  of block b1.
include bdcrecx1.

at selection-screen on value-request for p_infile.
   perform value_help.

start-of-selection.

clear:itab1[].
   call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
     exporting
       filename    = p_infile
       i_begin_col = '1'
       i_begin_row = '2'
       i_end_col   = '1'
       i_end_row   = '100'
     tables
       intern      = itab1.
   .


from itab1 you may get your excel details .


itab1 have only one column so you can change your internal table format record .

loop at record.

....

....

...

Endloop.

Read only

0 Likes
1,529

hello,

thank you for your reply.

but the program is working fine. i looked up at transaction SM35  and what i saw is there :

my batch-inputs dont start.

Read only

0 Likes
1,529

my batch-inputs are labeled as "NEW" not as processed ot wrong.

how can i process them ?

Read only

thangam_perumal
Contributor
0 Likes
1,529

Hi Cem,

              I gave suggestion for BDC program with Separate Z T-code.

If you want to run SM35 you have to change littele bit.

parameter:p_infile like rlgrap-filename obligatory.

***********************************************************

selection-screen begin of block b1 with frame.


selection-screen end  of block b1.
include bdcrecx1.

at selection-screen on value-request for p_infile.
   perform value_help.
  *********************************************************

just delete the coding between comment lines.

start-of-selection.

clear:itab1[].
   call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
     exporting
       filename    = p_infile     " instead of p_infile  you can provide your file path.
       i_begin_col = '1'
       i_begin_row = '2'
       i_end_col   = '1'
       i_end_row   = '100'
     tables
       intern      = itab1.
   .