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

Runtime error while using for all entries in bdc program

former_member612655
Participant
0 Likes
798

Hi experts,

I developed a bdc program as shown in below for uploading a excel file into sap system and also retreving the data from data base and downloading the error records also.

But when i run the below code the program goes into dump. Instead of for all entries i used inner joins also but the query is not processes. Can you please help me to find ou this

REPORT zbdc_call NO STANDARD PAGE HEADING LINE-SIZE 255.

tables :lfbk,bnka.

TYPE-POOLS truxs.

DATA flag TYPE c.

DATA cnt(2) TYPE n.

DATA t_cnt(6) TYPE n.

DATA l_cnt(5) TYPE n.

DATA rng(6) TYPE n.

DATA field(20).

*declaration to upload excel file

DATA it_raw TYPE truxs_t_text_data.

DATA: w_textout LIKE t100-text.

Data : Begin of ty_lfbk,

 lifnr like lfbk-lifnr,

banks like lfbk-banks,

bankl like lfbk-bankl,

bankn like lfbk-bankn,

koinh like lfbk-koinh,

bkref like lfbk-bkref,

  end of ty_lfbk.

data : begin of ty_bnka,

     banka like bnka-banka,

    brnch like bnka-brnch,

    bankl like bnka-bankl,

  end of ty_bnka.

* internal table

DATA: BEGIN OF ty_final OCCURS 0,

  lifnr like lfbk-lifnr,

banks like lfbk-banks,

bankl like lfbk-bankl,

bankn like lfbk-bankn,

koinh like lfbk-koinh,

banka like bnka-banka,

brnch like bnka-brnch,

bkref like lfbk-bkref,

END OF ty_final.

* Internal table to handle errors

DATA: BEGIN OF ty_error,

  lifnr like lfbk-lifnr,

banks like lfbk-banks,

bankl like lfbk-bankl,

bankn like lfbk-bankn,

koinh like lfbk-koinh,

banka like bnka-banka,

brnch like bnka-brnch,

bkref like lfbk-bkref,

err_msg(73) TYPE c,

END OF ty_error.

DATA : it_lfbk LIKE TABLE OF ty_lfbk WITH HEADER LINE,

      it_bnka LIKE TABLE OF ty_bnka WITH HEADER LINE,

      it_final LIKE TABLE OF ty_final WITH HEADER LINE.

DATA bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA: it_error LIKE TABLE OF ty_error WITH HEADER LINE.

*Used to stores error information from CALL TRANSACTION Function Module

DATA: BEGIN OF messtab OCCURS 0.

INCLUDE STRUCTURE bdcmsgcoll.

DATA: END OF messtab.

SELECTION-SCREEN BEGIN OF BLOCK Block1 WITH FRAME TITLE title.

PARAMETER:rad1 RADIOBUTTON GROUP rad USER-COMMAND frad1 DEFAULT 'X',

          rad2 RADIOBUTTON GROUP rad .

SELECTION-SCREEN END OF BLOCK block1.

SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-t02.
PArAMETERS: p_file TYPE rlgrap-filename MODIF ID g3.

SELECTION-SCREEN END OF BLOCK block3.
TYPE-POOLS slis.

AT SELECTION-SCREEN OUTPUT.

  IF rad1 = 'X'.

    LOOP AT SCREEN.

      IF screen-group1 = 'G2' ."OR screen-group1 = 'G4'.

        screen-active = '1'.

*        screen-input = 0.

      ELSEIF screen-group1 = 'G3'.

        screen-active = '0'.

      ENDIF.

      MODIFY SCREEN.

    ENDLOOP.

*    endif.
ELSEIF rad2 = 'X'.

    LOOP AT SCREEN.

      IF screen-group1 = 'G2' .

        screen-active = '0'.

      ELSEIF screen-group1 = 'G3'.

        screen-active = '1'.

      ENDIF.

      MODIFY SCREEN.

    ENDLOOP.

  ENDIF.


*SELECT lfbk~lifnr

*        lfbk~banks

*        lfbk~bankl

*        lfbk~bankn

*        lfbk~koinh

*        bnka~banka

*        bnka~brnch

*        lfbk~bkref

*    INTO TABLE it_final

*    FROM lfbk AS lfbk INNER JOIN bnka AS bnka

*      ON bnka~bankl EQ lfbk~bankl

*   WHERE lfbk~lifnr IN s_lifnr .

select lifnr banks bankl bankn koinh bkref from lfbk

    into table it_lfbk where lifnr in s_lifnr.

 if it_lfbk is not initial.

   select banka brnch bankl from bnka

     into table it_bnka FOR ALL ENTRIES IN it_lfbk

     where bankl = it_lfbk-bankl.

  endif.
 loop at it_lfbk .

    it_final-lifnr = it_lfbk-lifnr.

    it_final-banks = it_lfbk-banks.

    it_final-bankl = it_lfbk-bankl.

    it_final-bankn = it_lfbk-bankn.

    it_final-koinh = it_lfbk-koinh.

    it_final-bkref = it_lfbk-bkref.

 loop at it_bnka.

   it_final-banka  = it_bnka-banka.

   it_final-brnch = it_bnka-brnch.
append it_final.

   clear : it_final,

            it_lfbk,

            it_bnka.

    it_final-banks = it_lfbk-banks.

ENDLOOP.

endloop.

*endif.

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

* Initialisation *

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

INITIALIZATION.

MOVE 'FILE NAME' TO title.

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

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

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

* S T A R T O F S E L E C T I O N *

***********************************************************************
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

* I_FIELD_SEPERATOR = 'X'

* I_LINE_HEADER = 'X'

i_tab_raw_data = it_raw

i_filename = p_file

TABLES

i_tab_converted_data = it_final.

* EXCEPTIONS

* CONVERSION_FAILED = 1

* OTHERS = 2.

LOOP AT it_final.

perform bdc_dynpro      using 'SAPMF02K' '0101'.

perform bdc_field       using 'BDC_CURSOR'

                              'RF02K-LIFNR'.

perform bdc_field       using 'BDC_OKCODE'

                              '/00'.

perform bdc_field       using 'RF02K-LIFNR'

                              it_final-lifnr.

perform bdc_field       using 'RF02K-D0130'

                              'X'.

perform bdc_dynpro      using 'SAPMF02K' '0130'.

perform bdc_field       using 'BDC_CURSOR'

                              'LFBK-BKREF(01)'.

perform bdc_field       using 'BDC_OKCODE'

                              '=BANK'.

perform bdc_field       using 'LFBK-BANKS(01)'

                              it_final-banks.

perform bdc_field       using 'LFBK-BANKL(01)'

                              it_final-bankl.

perform bdc_field       using 'LFBK-BANKN(01)'

                              it_final-bankn.

perform bdc_field       using 'LFBK-KOINH(01)'

                              it_final-koinh.

perform bdc_field       using 'LFBK-BKREF(01)'

                              it_final-bkref.

perform bdc_dynpro      using 'SAPLBANK' '0100'.

perform bdc_field       using 'BDC_CURSOR'

                              'BNKA-BANKA'.

perform bdc_field       using 'BDC_OKCODE'

                              '=ENTR'.

perform bdc_field       using 'BNKA-BANKA'

                              it_final-banka.

perform bdc_field       using 'BNKA-BRNCH'

                              it_final-brnch.

perform bdc_dynpro      using 'SAPMF02K' '0130'.

perform bdc_field       using 'BDC_CURSOR'

                              'LFBK-BKREF(01)'.

perform bdc_field       using 'BDC_OKCODE'

                              '=UPDA'.

*call transaction to update customer instalment text

CALL TRANSACTION 'XK02' USING bdcdata MODE 'N' UPDATE 'S'

MESSAGES INTO messtab.

*Check if update was succesful

IF sy-subrc NE 0.

*Retrieve error messages displayed during BDC update

LOOP AT messtab WHERE msgtyp = 'E'.

*Builds actual message based on info returned from Call transaction

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

msgid = messtab-msgid

msgnr = messtab-msgnr

msgv1 = messtab-msgv1

msgv2 = messtab-msgv2

msgv3 = messtab-msgv3

msgv4 = messtab-msgv4

IMPORTING

message_text_output = w_textout.

ENDLOOP.

* Build error table ready for output

it_error-lifnr = it_final-lifnr.

it_error-banks = it_final-banks.

it_error-bankl = it_final-bankl.

it_error-bankn = it_final-bankn.

it_error-koinh = it_final-koinh.

it_error-banka = it_final-banka.

it_error-brnch = it_final-brnch.

it_error-bkref = it_final-bkref.

it_error-err_msg = w_textout.

APPEND it_error.

CLEAR it_error.

ENDIF.

* Clear bdc data table

CLEAR: bdcdata.

REFRESH: bdcdata.

ENDLOOP.

DATA:IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,

     WA_FCAT TYPE SLIS_FIELDCAT_ALV,

     WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

  REFRESH:IT_FCAT[].

  PERFORM FCAT USING: 'LIFNR' 'VENDOR',

                      'BANKS' 'COUNTRY KEY',

                      'BANKL' 'ACC NUM',

                      'BANKN' 'ACC key',

                      'KOINH' 'ACCOUNT HOLDER',

                      'BANKA' 'BANK NAME',

                      'BRNCH' 'BRANCH',

                      'bkref' 'IFSC CODE'.

*ENDFORM.                    " BUILD_FCAT

*FORM DISPLAY_OUTPUT .

  WA_LAYOUT-ZEBRA = 'X'.

  WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

   EXPORTING

*     I_INTERFACE_CHECK        = ' '

*     I_BYPASSING_BUFFER       = ' '

*     I_BUFFER_ACTIVE          = ' '

      I_CALLBACK_PROGRAM       = SY-REPID

      I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'

*     I_CALLBACK_TOP_OF_PAGE   = ' '

*     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '

*     I_CALLBACK_HTML_END_OF_LIST       = ' '

*     I_STRUCTURE_NAME         =

*     I_BACKGROUND_ID          = ' '

*     I_GRID_TITLE             =

*     I_GRID_SETTINGS          =

     IS_LAYOUT                = WA_LAYOUT

     IT_FIELDCAT              = IT_FCAT

*     IT_EXCLUDING             =

*     IT_SPECIAL_GROUPS        =

*      IT_SORT                  = IT_SORT

*     IT_FILTER                =

*     IS_SEL_HIDE              =

*     I_DEFAULT                = 'X'

*     I_SAVE                   = ' '

*     IS_VARIANT               =

*     IT_EVENTS                =

*     IT_EVENT_EXIT            =

*     IS_PRINT                 =

*     IS_REPREP_ID             =

*     I_SCREEN_START_COLUMN    = 0

*     I_SCREEN_START_LINE      = 0

*     I_SCREEN_END_COLUMN      = 0

*     I_SCREEN_END_LINE        = 0

*     I_HTML_HEIGHT_TOP        = 0

*     I_HTML_HEIGHT_END        = 0

*     IT_ALV_GRAPHICS          =

*     IT_HYPERLINK             =

*     IT_ADD_FIELDCAT          =

*     IT_EXCEPT_QINFO          =

*     IR_SALV_FULLSCREEN_ADAPTER        =

* IMPORTING

*     E_EXIT_CAUSED_BY_CALLER  =

*     ES_EXIT_CAUSED_BY_USER   =

   TABLES

     T_OUTTAB                 = IT_Error

* EXCEPTIONS

*     PROGRAM_ERROR            = 1

*     OTHERS                   = 2

   .
*ENDFORM.

FORM FCAT  USING  FIELD TEXT.

 WA_FCAT-FIELDNAME = FIELD.

  WA_FCAT-SELTEXT_M = TEXT.

 APPEND WA_FCAT TO IT_FCAT.

  CLEAR WA_FCAT.

  endform.

  form download.

*    set PF-STATUS 'stat'.

*  at USER-COMMAND.

   if sy-ucomm = 'download'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

** BIN_FILESIZE =

**FILENAME = F_EFILE

FILETYPE = 'asc'

*** APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

** HEADER = '00'

** TRUNC_TRAILING_BLANKS = ' '

** WRITE_LF = 'X'

** COL_SELECT = ' '

** COL_SELECT_MASK = ' '

** DAT_MODE = ' '

** CONFIRM_OVERWRITE = ' '

** NO_AUTH_CHECK = ' '

** CODEPAGE = ' '

** IGNORE_CERR = ABAP_TRUE

** REPLACEMENT = '#'

** WRITE_BOM = ' '

** TRUNC_TRAILING_BLANKS_EOL = 'X'

** WK1_N_FORMAT = ' '

** WK1_N_SIZE = ' '

** WK1_T_FORMAT = ' '

** WK1_T_SIZE = ' '

** WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE

** SHOW_TRANSFER_STATUS = ABAP_TRUE

** IMPORTING

** FILELENGTH =

TABLES

DATA_TAB = IT_Error

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.
IF SY-SUBRC <> 0.

* Implement suitable error handling here

ENDIF.

endif.

ENDFORM. " DOWNLOAD_ERRFIL

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

* Start new screen *

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

FORM bdc_dynpro USING program dynpro.

CLEAR bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

APPEND bdcdata.

ENDFORM. "bdc_dynpro

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

* Insert field *

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

FORM bdc_field USING fnam fval.

* if fval <> nodata.

CLEAR bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

APPEND bdcdata.

* endif.

ENDFORM. "bdc_field
2 REPLIES 2
Read only

michael_piesche
Active Contributor
691

You are too funny!

In two questions you ask how to do pretty much the entire report for uploading/downloading a file, one gets closed by moderator and the second one gives you an answer that might work for you.

An now you have a question to get us to analyze your entire report and look for errors, when you didn’t even post the error information itself and where it happened.


have you considered taking some training, or at least some ABAP literature?


if some of us answer this, can we also count on you coming back tomorrow with the next issue?

I wonder whose system you are messing around with.

Sorry for sounding a little bit snotty, but you don’t seem to put much effort into your issues at all.

Read only

Sandra_Rossi
Active Contributor
691

Please attach the short dump.