Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8927

Re: BDC not displaying errored data

$
0
0

Hi Srikant,

please see this sample code, and change it accordingly for transaction code, fields, etc.

Please see those who are in bold letters.

Still if you have any issue, then please revert me back.

 

 

report ZFB01_POST_DOCUMENT

        no standard page heading line-size 255.

 

INCLUDE zbdcrec.

 

TYPE-POOLS : TRUXS.

 

TYPESBEGIN OF ty_input,

 

        Your final data.

 

END OF ty_input.

 

 

DATA: it_input TYPE STANDARD TABLE OF ty_input WITH HEADER LINE ,

       wa_input TYPE ty_input.

DATA : BEGIN OF options.

         INCLUDE STRUCTURE ctu_params.

DATA : END OF options.

DATA: i_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,

       l_message LIKE bapiret2-message.

DATA: p_mode TYPE c.

DATA  BEGIN OF it_error OCCURS 1.

DATA : text(100TYPE c.

DATA  END   OF it_error.

DATA  BEGIN OF it_success OCCURS 1.

DATAtext(100) TYPE c.

DATA  END   OF it_success.

DATA: it_raw TYPE truxs_t_text_data.

 

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

* sELECTION sCREEN

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

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

 

PARAMETERS : p_path LIKE rlgrap-filename OBLIGATORY.

SELECTION-SCREEN : END   OF BLOCK b1.

SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECTION-SCREEN SKIP 1.

PARAMETERS : mode_a      RADIOBUTTON    GROUP  r1,

              mode_n      RADIOBUTTON    GROUP  r1.

SELECTION-SCREEN : END   OF BLOCK b2.

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

* AT SELECTION SCREEN

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

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

   CALL FUNCTION 'F4_FILENAME'

     EXPORTING

       field_name = 'P_FILE '

     IMPORTING

       file_name  = p_path.

 

START-OF-SELECTION.

   CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

     EXPORTING

       i_line_header        = 'X'

       i_tab_raw_data       = it_raw       " WORK TABLE

       i_filename           = p_path

     TABLES

       i_tab_converted_data = it_input[]  "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.

 

   LOOP AT it_input.

   IF sy-tabix EQ 1 "for first  row

     CONTINUE.

   ENDIF.

 

ENDLOOP.

*--------------------------------------------------------------------*\

* start of selection

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

START-OF-SELECTION.

 

  PERFORM upload_data.

 

 

*   Report for success

  PERFORM  success_text.

*   Report for Error

   PERFORM  error_text.

 

END-OF-SELECTION.

*

*  PERFORM bdc_transaction USING 'FB01'.

*

*  PERFORM close_group.

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

*&      Form  UPLOAD_DATA

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

*       text

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

*  -->  p1        text

*  <--  p2        text

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

form UPLOAD_DATA .

 

    IF mode_a EQ 'X'.

     p_mode = 'A'.

   ELSEIF mode_n EQ 'X'.

     p_mode = 'N'.

   ENDIF.

 

   options-defsize = 'X'.

   options-updmode = ''.

   options-dismode = p_mode.

 

   LOOP AT it_input INTO wa_input.

 

   Your BDC data (code for BDC).

 

CALL TRANSACTION 'txn. code' USING bdcdata

                             OPTIONS FROM options

                             MESSAGES INTO i_messtab.

 

 

     IF SY-SUBRC NE 0.

       CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'

         EXPORTING

           id         = sy-msgid

           number     = sy-msgno

           language   = sy-langu

           textformat = 'ASC'

           message_v1 = sy-msgv1

           message_v2 = sy-msgv2

           message_v3 = sy-msgv3

           message_v4 = sy-msgv4

         IMPORTING

           message    = l_message.

       .

       CONCATENATE l_message '-' wa_input-field1 wa_input-field2 wa_input-field3INTO it_error-text

       SEPARATED BY ' '.

       APPEND it_error.

     ELSE.

       CONCATENATE 'DATA UPLOADED SUCCESSFULLY :' wa_input-field1  wa_input-field2 wa_input-field3

       INTO it_success-text SEPARATED BY ' '.

       APPEND it_success.

     ENDIF.

     REFRESH bdcdata.

     CLEAR: wa_input,l_message.

ENDLOOP.

***ENDLOOP.

endform.

 

 

 

                    " UPLOAD_DATA

 

FORM success_text .

 

   LOOP AT it_success.

     AT FIRST.

       WRITE :/10  'Following records successfully uploaded'.

       ULINE.

     ENDAT.

     WRITE :/10  it_success-text.

   ENDLOOP.

 

ENDFORM.

 

FORM error_text .

 

  LOOP AT it_error.

     AT FIRST.

       WRITE :/10  'Following records  are not uploaded'.

       ULINE.

     ENDAT.

     WRITE :/10  it_error-text.

  ENDLOOP.

ENDFORM.


Viewing all articles
Browse latest Browse all 8927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>