2013 Nov 13 7:48 AM
Hello All,
I have requirement that i need to show a success message for all the sales order that are updated through a custom report at the end of the report i have used bdc
CALL TRANSACTION 'VA02'
USING bdcdata
MODE lc_n
MESSAGES INTO t_message_tab .
in this message is shown for the last sales order that is updated but i need to show total number of orders that are updated.
Thanks in advance.
2013 Nov 13 7:57 AM
Hi , May be you are refreshing the internal table t_message_tab for every document update. append the message tab into another internal table on that time we can have all the error/success messages in one internal table.
2013 Nov 13 8:12 AM
Hi Anurag Sinha
Simple try like this
TYPES : BEGIN OF TY_FILE,
MBRSH TYPE MARA-MBRSH,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
MEINS TYPE MARA-MEINS,
END OF TY_FILE.
DATA : I_FILE TYPE TABLE OF TY_FILE .
DATA : WA_FILE TYPE TY_FILE .
DATA : LV_MSG TYPE STRING .
**********************BDC DATA DECLARARATIONS
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
BREAK-POINT .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\MARADATA.TXT'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = I_FILE.
LOOP AT I_FILE INTO WA_FILE .
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MBRSH'
WA_FILE-MBRSH.
perform bdc_field using 'RMMG1-MTART'
WA_FILE-MTART.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
WA_FILE-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
WA_FILE-MEINS.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
CALL TRANSACTION 'MM01'
USING bdcdata
UPDATE 'A'
MODE 'N'
MESSAGES INTO MESSTAB .
If SY-SUBRC = 0.
Perform display_success_rec.
Else .
Perform display_error_rec.
Endif.
CLEAR WA_FILE .
REFRESH BDCDATA.
CLEAR BDCDATA.
REFRESH MESSTAB .
CLEAR MESSTAB.
ENDLOOP .
*----------------------------------------------------------------------*
* 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
*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FNAM text
* -->FVAL text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
* ENDIF.
ENDFORM. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form display_success_rec
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_success_rec .
READ TABLE MESSTAB WITH KEY MSGTYP = 'S' .
WRITE : / 'material is created with no:' , messtab-msgv1 COLOR 5.
ENDFORM. " display_success_rec
*&---------------------------------------------------------------------*
*& Form display_error_rec
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_error_rec .
LOOP AT MESSTAB WHERE MSGTYP = 'E' .
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = MESSTAB-MSGID
LANG = 'E'
NO = MESSTAB-MSGNR
V1 = MESSTAB-MSGV1
V2 = MESSTAB-MSGV2
V3 = MESSTAB-MSGV3
V4 = MESSTAB-MSGV4
IMPORTING
MSG = LV_MSG.
WRITE / lv_msg COLOR 6.
ENDLOOP .
ENDFORM. " display_error_rec
*************************************************************************
FLAT FILE SHOULD BE AS BELOW
*****************************************************************
P COUP DESC5 KGS
P COUP DESC6 KGS
P COUP DESC7 KGx
P COUP DESC8 KGS
2013 Nov 13 7:59 AM
Hello Anurag.
Get the no.of records that are successfully updated and use CONCATENATE statement to compile a message variable and finally display using MESSAGE statement.
Like,
CONCATENATE '3' 'RECORDS UPDATED' into var SEPARATED BY SPACE.
MESSAGE var TYPE 'S'.
Regards.
2013 Nov 13 7:59 AM
Append t_message_tab to another global table. and show output as per the global table.
Regards,
Supratik
2013 Nov 13 7:59 AM
You are calling it in a loop i believe.. So before refreshing data store in global table.
2013 Nov 13 8:02 AM
Hi Anurag,
You can display all the sales order updated as log using ALV grid display.
DATA: V_TITLE TYPE LVC_TITLE VALUE 'Log display'.
DATA: wa_disvariant LIKE disvariant.
wa_disvariant-report = sy-repid.
wa_disvariant-username = sy-uname.
* Call Function module for GRID display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = T_FIELDCAT1
I_GRID_TITLE = V_TITLE
I_SAVE = 'X'
* IS_VARIANT = wa_disvariant
IT_EVENTS = GT_EVENTS
TABLES
T_OUTTAB = LT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
LEAVE LIST-PROCESSING.
ENDIF.
2013 Nov 13 8:20 AM
Hi Anurag Sinha,
As suggested by the All you need to store every sales order updated by the CALL TRANSACTION statement you have to append success information into another internal table and you have display that internal table after completion your loop. Other you can save this data in Application Log for later review also.
CALL TRANSACTION 'VA02'
USING bdcdata
MODE lc_n
MESSAGES INTO t_message_tab .
data lt_success_msg type standard table of <type which you need to display>.
data ls_success_msg like line of lt_success_msg.
loop t_message_tab into ls_message_tab where msgtyp = 'S'.
move : <field1> to ls_success_msg-field1.
etc.
append ls_success_msg to lt_success_msg.
clear: ls_success_msg, ls_message_tab.
endloop.
endloop. " this endloop is of sales order internal table.
I hope you would understand it.
Regards,
Venkat