Skip to Content

Issue with to capture a success message into BDC CALL TRANSACTION METHOD

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }


TYPES: BEGIN OF LINE_TYPE,
ANLN1 TYPE ANLN1,
BLDAT(10) TYPE C,
BUDAT(10) TYPE C,
UBZDT(10) TYPE C,
ANBTR(100) TYPE c,
MENGE(100) TYPE c,
MEINS TYPE MEINS,
END OF LINE_TYPE.

DATA IT_MAT TYPE TABLE OF LINE_TYPE WITH HEADER LINE.
DATA IT_EXCEL TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
DATA IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.
DATA: IT_MESSAGE TYPE STANDARD TABLE OF BDCMSGCOLL INITIAL SIZE 1,
WA_MESSAGE TYPE BDCMSGCOLL.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS P_FILE TYPE IBIPPARMS-PATH.
SELECTION-SCREEN END OF BLOCK B1.

DATA : P_MSG(1000) TYPE C,
V_TOTAL(1000) TYPE C.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM BROWSE_FILE.

START-OF-SELECTION.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM CONVERT_IT_EXCEL_TO_IT_MAT.
PERFORM VALIDATE_DATA.


FORM BROWSE_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_FILE
.

ENDFORM.

FORM UPLOAD_EXCEL_FILE .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 7
I_END_ROW = 1000
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDFORM.

FORM CONVERT_IT_EXCEL_TO_IT_MAT .
LOOP AT IT_EXCEL.
CASE IT_EXCEL-COL.
WHEN 1.
IT_MAT-ANLN1 = IT_EXCEL-VALUE.
WHEN 2.
IT_MAT-BLDAT = IT_EXCEL-VALUE.
WHEN 3.
IT_MAT-BUDAT = IT_EXCEL-VALUE.
WHEN 4.
IT_MAT-UBZDT = IT_EXCEL-VALUE.
WHEN 5.
IT_MAT-ANBTR = IT_EXCEL-VALUE.
WHEN 6.
IT_MAT-MENGE = IT_EXCEL-VALUE.
WHEN 7.
IT_MAT-MEINS = IT_EXCEL-VALUE.
APPEND IT_MAT.
CLEAR: IT_MAT,IT_EXCEL.
ENDCASE.
ENDLOOP.

ENDFORM.

FORM VALIDATE_DATA .
LOOP AT IT_MAT.
CLEAR : p_msg ,V_TOTAL.
REFRESH IT_BDCDATA.
IF SY-TABIX = 1.
CONTINUE.
ENDIF.


PERFORM fill_screen USING 'SAPLAMDP' '0100'.
PERFORM fill_field USING 'BDC_OKCODE' '/00'.
PERFORM fill_field USING 'RAIFP3-XBANL' 'X'.
PERFORM fill_field USING 'RAIFP2-ANLN1' IT_MAT-ANLN1.
*PERFORM fill_field USING 'RAIFP2-ANLN2' IT_MAT-ANLN2.
PERFORM fill_field USING 'RAIFP1-BLDAT' IT_MAT-BLDAT.
PERFORM fill_field USING 'RAIFP1-BUDAT' IT_MAT-BUDAT.
PERFORM fill_field USING 'RAIFP1-UBZDT' IT_MAT-UBZDT.
PERFORM fill_field USING 'RAIFP2-ANBTR' IT_MAT-ANBTR.
PERFORM fill_field USING 'RAIFP2-MENGE' IT_MAT-MENGE.
PERFORM fill_field USING 'RAIFP2-MEINS' IT_MAT-MEINS.


PERFORM fill_screen USING 'SAPLAMDP' '0100'.
PERFORM fill_field USING 'BDC_OKCODE' '=SHWD'.


PERFORM fill_screen USING 'SAPMSSY0' '0120'.
PERFORM fill_field USING 'BDC_OKCODE' '=BUCH'.

CALL TRANSACTION 'ABNAN' USING IT_BDCDATA MODE 'A' UPDATE 'A' MESSAGES INTO it_message.
LOOP AT it_message INTO WA_MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = '-D'
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = p_msg
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDLOOP.
CONCATENATE IT_MAT-ANLN1 IT_MAT-BLDAT IT_MAT-BUDAT p_msg INTO V_TOTAL SEPARATED BY SPACE.
WRITE:/ V_TOTAL.
ENDLOOP.
ENDFORM.


FORM fill_screen USING p_pgm p_screen.
CLEAR IT_BDCDATA.
IT_BDCDATA-program = p_pgm.
IT_BDCDATA-dynpro = p_screen.
IT_BDCDATA-dynbegin = 'X'.
APPEND IT_BDCDATA.
ENDFORM.

FORM fill_field USING p_fnam p_fval.
CLEAR IT_BDCDATA.
IF p_fval IS NOT INITIAL.
IT_BDCDATA-fnam = p_fnam.
IT_BDCDATA-fval = p_fval.
APPEND IT_BDCDATA.
ENDIF.
ENDFORM.

when i uploading a record through BDC in its didnt capture a success message into a it_message .

even when i upload a record have a error its showing record in a it_message .

but its dosnt show in it_message.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 26, 2019 at 07:31 AM
    Hi SHUBHAM ,
    
    ***Tyr like this
    
    *perform bdc_transaction using 'MEK1'.
        CALL TRANSACTION 'MEK1' USING IT_BDC UPDATE 'S' MODE 'P' MESSAGES INTO MESSTAB.
        IF SY-SUBRC = 0.
    *      MESSAGE S000(ZCOST_PB00) WITH LS_INPUT-MATNR LS_INPUT-WERKS.
          LS_OUTPUT-STATUS = 'Success'.
        ELSE.
    *      MESSAGE E001(ZCOST_PB00) WITH LS_INPUT-MATNR LS_INPUT-WERKS.
          LS_OUTPUT-STATUS = 'Failed'.
        ENDIF.
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.