2007 Jul 21 9:35 AM
hi
i have uploaded data from flat file for VA01 successfully.
now system generates sales order no automatically after uploading data.
i want to show this sales order no in bdc report.
the difficult is that sales order no vbeln itself is a primary key so how can i display
in the bdc report the system generated sales order no.
important vbeln itself is a primary key.
since it is missing how can i display in the bdc report sales order no.
we can not use select querry for this for sure.
thanx
rocky
2007 Jul 21 10:45 AM
all the message will be saved in a message table in bdc...where ever message type is 'S' then it resembles that its posted catch that message to a itab and display...below is a prg that i used to catch the document no for prd posting...just look at that.
it consists of a include file ...im displaying it below the main program
the messages are caught in the main program after a call transaction is made...
MAIN PROGRAM
REPORT ZBDC_POSTING
NO STANDARD PAGE HEADING LINE-SIZE 255
MESSAGE-ID ZPP.
******************
INCLUDE BDCRECX1.
******************
*PARAMETERS: dataset(132) LOWER CASE.
TYPE-POOLS :SLIS.
TABLES : MAKT, MKAL.
DATA: WK_ELPRO TYPE MKAL-ALORT,
WK_MAKT TYPE MAKT-MAKTX,
WK_SUCCESS(5) TYPE C,
WK_FAILURE(5) TYPE C,
L_MSTRING(480),
T_DATE TYPE ZSERVICE_DATE,
WK_LINES(5) TYPE C,
LINES(5) TYPE C,
WK_LEN(150) TYPE C,
WK_ALP TYPE I,
LENT TYPE I,
B(4).
DATA: ALVFLD TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
V_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,
WK_EVENTS LIKE LINE OF V_EVENTS,
IT_LIST_COMMENTS TYPE SLIS_T_LISTHEADER,
WK_LIST_COMMENTS LIKE LINE OF IT_LIST_COMMENTS,
WA_COLOR TYPE LVC_S_SCOL,
WK_LAYOUT TYPE SLIS_LAYOUT_ALV.
CONSTANTS: C_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME
VALUE 'F_TOP_OF_PAGE'.
--
Generated data section with specific formatting - DO NOT CHANGE ***
DATA: BEGIN OF RECORD OCCURS 0,
BUDAT_002(010),
BKTXT_004(025),
MATNR_005(018),
WERKS_006(004),
ALORT_007(004),
ERFMG_008(017),
END OF RECORD.
End generated data section ***
----
DATA: BEGIN OF MESSAGES OCCURS 0, "TO STORE FINAL STATUS DISPLAY
BUDAT_002(010),
BKTXT_004(025),
MATNR_005(018),
MAKTX TYPE MAKT-MAKTX,
WERKS_006(004),
ALORT_007(004),
ERFMG_008(017),
MSG_E(100),
MSG_S(100),
MSGTYP TYPE C,
LINE_COLOR(4),
END OF MESSAGES.
DATA: BEGIN OF ST_RECORD1 ,
MATNR_005(018),
WERKS_006(004),
BUDAT_002(010),
BKTXT_004(025),
ERFMG_007(017),
ERFMG_008(017),
ALORT_007(004),
END OF ST_RECORD1.
DATA : RECORD1 LIKE TABLE OF ST_RECORD1 WITH HEADER LINE,
IT_EXCEL LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE,
MESSTAB1 LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
IT_ACC LIKE TABLE OF RECORD WITH HEADER LINE,
IT_REJ LIKE TABLE OF RECORD WITH HEADER LINE.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_FILE TYPE LOCALFILE OBLIGATORY .
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
STATIC = 'X'
CHANGING
FILE_NAME = P_FILE.
AT SELECTION-SCREEN ON P_FILE.
WK_LEN = P_FILE.
CONDENSE WK_LEN NO-GAPS.
LENT = STRLEN( WK_LEN ).
WK_ALP = LENT - 4.
B = WK_LEN+WK_ALP(LENT).
IF ( B NE '.txt' ) AND ( B NE '.xls' ).
MESSAGE E939.
CLEAR P_FILE.
STOP.
ENDIF.
START-OF-SELECTION.
PERFORM UPLOAD_FUN.
PERFORM OPEN_GROUP.
PERFORM FILL_BDC_TABLE.
PERFORM CLOSE_GROUP.
PERFORM ASSIGN_COLORS.
PERFORM F_EVENT_BUILD.
SORT MESSAGES BY MATNR_005 ASCENDING.
PERFORM ASSIGN_COLUMNS.
PERFORM COUNT.
IF CTU = 'X'.
PERFORM ALV.
ENDIF.
FREE:MESSAGES,MESSTAB1,RECORD1.
END-OF-SELECTION.
--
FORM UPLOAD_FUN.
REFRESH: RECORD1, IT_ACC, IT_REJ, RECORD, MESSAGES, MESSTAB1, IT_EXCEL.
PERFORM FETCH_FROM_FLAT_FILE.
CLEAR IT_EXCEL.
DESCRIBE TABLE IT_EXCEL.
IF SY-TFILL = 0.
MESSAGE I937.
STOP.
ENDIF.
LOOP AT IT_EXCEL.
CASE IT_EXCEL-COL.
WHEN '0001'.
MOVE: IT_EXCEL-VALUE TO RECORD1-MATNR_005.
WHEN '0002'.
MOVE: IT_EXCEL-VALUE TO RECORD1-WERKS_006.
WHEN '0003'.
MOVE: IT_EXCEL-VALUE TO RECORD1-BUDAT_002.
WHEN '0004'.
MOVE: IT_EXCEL-VALUE TO RECORD1-BKTXT_004.
WHEN '0005'.
MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_007.
WHEN '0006'.
MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_008.
WHEN '0007'.
MOVE: IT_EXCEL-VALUE TO RECORD1-ALORT_007.
ENDCASE.
AT END OF ROW.
APPEND RECORD1.
CLEAR RECORD1.
ENDAT.
ENDLOOP.
CLEAR RECORD1.
DELETE RECORD1 WHERE MATNR_005 EQ ' '.
--
DELETE RECORD1 WHERE ( ERFMG_007 = 0 OR ERFMG_007 = ' ' )
AND ( ERFMG_008 = 0 OR ERFMG_008 = ' ' ).
DESCRIBE TABLE RECORD1[].
IF SY-TFILL > 0.
--
LOOP AT RECORD1 WHERE ERFMG_007 NE 0 AND ERFMG_007 NE ' '.
MOVE: RECORD1-BUDAT_002 TO IT_ACC-BUDAT_002,
RECORD1-BKTXT_004 TO IT_ACC-BKTXT_004,
RECORD1-MATNR_005 TO IT_ACC-MATNR_005,
RECORD1-WERKS_006 TO IT_ACC-WERKS_006,
RECORD1-ERFMG_007 TO IT_ACC-ERFMG_008.
APPEND IT_ACC.
CLEAR: IT_ACC,RECORD1.
ENDLOOP.
--
LOOP AT IT_ACC.
SELECT SINGLE ELPRO INTO WK_ELPRO FROM MKAL CLIENT SPECIFIED
WHERE MANDT = SY-MANDT
AND MATNR = IT_ACC-MATNR_005
AND WERKS = IT_ACC-WERKS_006.
MOVE WK_ELPRO TO IT_ACC-ALORT_007.
MODIFY IT_ACC.
CLEAR: WK_ELPRO, IT_ACC.
ENDLOOP.
--
LOOP AT RECORD1 WHERE ERFMG_008 NE 0 AND ERFMG_008 NE ' '.
MOVE: RECORD1-BUDAT_002 TO IT_REJ-BUDAT_002,
RECORD1-BKTXT_004 TO IT_REJ-BKTXT_004,
RECORD1-MATNR_005 TO IT_REJ-MATNR_005,
RECORD1-WERKS_006 TO IT_REJ-WERKS_006,
RECORD1-ERFMG_008 TO IT_REJ-ERFMG_008,
RECORD1-ALORT_007 TO IT_REJ-ALORT_007.
APPEND IT_REJ.
CLEAR: IT_REJ, RECORD1.
ENDLOOP.
--
APPEND LINES OF IT_ACC TO RECORD.
APPEND LINES OF IT_REJ TO RECORD.
FREE : IT_REJ, IT_ACC, RECORD1.
ELSE.
MESSAGE I937.
STOP.
ENDIF.
ENDFORM. " UPLOAD_FUN
--
FORM FILL_BDC_TABLE.
IF NOT RECORD[] IS INITIAL.
LOOP AT RECORD.
PERFORM BDC_DYNPRO USING 'SAPLBARM' '0800'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RM61B-BKTXT'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ISTDA'.
PERFORM BDC_FIELD USING 'RM61B-BUDAT' RECORD-BUDAT_002.
PERFORM BDC_FIELD USING 'RM61B-BKTXT' RECORD-BKTXT_004.
PERFORM BDC_FIELD USING 'RM61B-MATNR' RECORD-MATNR_005.
PERFORM BDC_FIELD USING 'RM61B-WERKS' RECORD-WERKS_006.
PERFORM BDC_FIELD USING 'RM61B-ALORT' RECORD-ALORT_007.
PERFORM BDC_FIELD USING 'RM61B-ERFMG' RECORD-ERFMG_008.
PERFORM BDC_DYNPRO USING 'SAPLCOWB' '0130'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' '=WEIT'.
PERFORM BDC_FIELD USING 'BDC_CURSOR' 'G_COWB_HEADER-MNGTXT'.
PERFORM BDC_TRANSACTION USING 'MFBF'.
CLEAR MESSTAB.
APPEND LINES OF MESSTAB TO MESSTAB1.
CLEAR MESSTAB1.
LOOP AT MESSTAB1 WHERE MSGTYP = 'S' OR MSGTYP = 'E' OR MSGTYP = 'W'.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB1-MSGSPRA
AND ARBGB = MESSTAB1-MSGID
AND MSGNR = MESSTAB1-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB1-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB1-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB1-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB1-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB1-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB1-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB1-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB1-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
IF MESSTAB1-MSGTYP = 'E'.
MOVE L_MSTRING TO MESSAGES-MSG_E.
MOVE 'E' TO MESSAGES-MSGTYP.
ELSEIF MESSTAB1-MSGTYP = 'S'.
MOVE L_MSTRING TO MESSAGES-MSG_S.
MOVE 'S' TO MESSAGES-MSGTYP.
ENDIF.
ENDIF.
CLEAR L_MSTRING.
ENDLOOP.
MOVE-CORRESPONDING RECORD TO MESSAGES.
SELECT SINGLE MAKTX INTO WK_MAKT FROM MAKT CLIENT SPECIFIED
WHERE MANDT = SY-MANDT
AND MATNR = MESSAGES-MATNR_005.
MOVE:WK_MAKT TO MESSAGES-MAKTX.
APPEND MESSAGES.
CLEAR: MESSAGES, WK_MAKT, MESSTAB1.
REFRESH MESSTAB1.
ENDLOOP.
ENDIF.
ENDFORM. "fill_bdc_table
--
FORM ASSIGN_COLUMNS .
REFRESH ALVFLD.
MOVE :'1' TO ALVFLD-COL_POS.
MOVE :'MATNR_005' TO ALVFLD-FIELDNAME.
MOVE :'PART NO' TO ALVFLD-SELTEXT_M.
MOVE :'X' TO ALVFLD-FIX_COLUMN.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'2' TO ALVFLD-COL_POS.
MOVE :'MAKTX' TO ALVFLD-FIELDNAME.
MOVE :'DESCRIPTION' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'3' TO ALVFLD-COL_POS.
MOVE :'WERKS_006' TO ALVFLD-FIELDNAME.
MOVE :'PLANT' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'4' TO ALVFLD-COL_POS.
MOVE :'BUDAT_002' TO ALVFLD-FIELDNAME.
MOVE :'POSTING DATE' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'5' TO ALVFLD-COL_POS.
MOVE :'BKTXT_004' TO ALVFLD-FIELDNAME.
MOVE :'SHIFT' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'6' TO ALVFLD-COL_POS.
MOVE :'ERFMG_008' TO ALVFLD-FIELDNAME.
MOVE :'QTY' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'7' TO ALVFLD-COL_POS.
MOVE :'ALORT_007' TO ALVFLD-FIELDNAME.
MOVE :'STGLOC' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'8' TO ALVFLD-COL_POS.
MOVE :'MSG_E' TO ALVFLD-FIELDNAME.
MOVE :'ERRORS' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
MOVE :'9' TO ALVFLD-COL_POS.
MOVE :'MSG_S' TO ALVFLD-FIELDNAME.
MOVE :'STATUS' TO ALVFLD-SELTEXT_M.
APPEND ALVFLD.CLEAR ALVFLD.
ENDFORM. " assign_columns
--
FORM F_EVENT_BUILD .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS[].
READ TABLE V_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO WK_EVENTS.
WK_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
WK_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
IF SY-SUBRC = 0.
MOVE C_FORMNAME_TOP_OF_PAGE TO WK_EVENTS-FORM.
MODIFY V_EVENTS FROM WK_EVENTS INDEX SY-TABIX.
ENDIF.
ENDFORM. " f_event_build
--
FORM F_TOP_OF_PAGE.
WRITE SY-DATUM TO T_DATE.
CLEAR: IT_LIST_COMMENTS[].
WK_LIST_COMMENTS-TYP = 'H'. "H=Header, S=Selection, A=Action
WK_LIST_COMMENTS-KEY = ''.
WK_LIST_COMMENTS-INFO = 'UPLOAD STATUS FOR PRODUCTION POSTING'.
APPEND WK_LIST_COMMENTS TO IT_LIST_COMMENTS.
CLEAR WK_LIST_COMMENTS.
WK_LIST_COMMENTS-TYP = 'S'. "H=Header, S=Selection, A=Action
WK_LIST_COMMENTS-KEY = ''.
CONCATENATE 'Uploaded Date:' T_DATE INTO WK_LIST_COMMENTS-INFO
SEPARATED BY SPACE.
APPEND WK_LIST_COMMENTS TO IT_LIST_COMMENTS.
CLEAR WK_LIST_COMMENTS.
DESCRIBE TABLE MESSAGES LINES WK_LINES.
LINES = WK_LINES.
WK_LIST_COMMENTS-TYP = 'S'. "H=Header, S=Selection, A=Action
WK_LIST_COMMENTS-KEY = ''.
CONCATENATE 'Total No of records:' LINES INTO WK_LIST_COMMENTS-INFO
SEPARATED BY SPACE.
APPEND WK_LIST_COMMENTS TO IT_LIST_COMMENTS.
CLEAR WK_LIST_COMMENTS.
WK_LIST_COMMENTS-TYP = 'S'. "H=Header, S=Selection, A=Action
WK_LIST_COMMENTS-KEY = ''.
CONCATENATE 'Successfull Entries:' WK_SUCCESS INTO
WK_LIST_COMMENTS-INFO SEPARATED BY SPACE.
APPEND WK_LIST_COMMENTS TO IT_LIST_COMMENTS.
CLEAR WK_LIST_COMMENTS.
WK_LIST_COMMENTS-TYP = 'S'. "H=Header, S=Selection, A=Action
WK_LIST_COMMENTS-KEY = ''.
CONCATENATE 'Failed Entries:' WK_FAILURE INTO WK_LIST_COMMENTS-INFO
SEPARATED BY SPACE.
APPEND WK_LIST_COMMENTS TO IT_LIST_COMMENTS.
CLEAR WK_LIST_COMMENTS.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = IT_LIST_COMMENTS.
ENDFORM. "F_TOP_OF_PAGE
--
FORM ASSIGN_COLORS .
LOOP AT MESSAGES.
CASE MESSAGES-MSGTYP.
WHEN 'E'.
MESSAGES-LINE_COLOR = 'C601'.
WHEN 'S'.
MESSAGES-LINE_COLOR = 'C501'.
ENDCASE.
MODIFY MESSAGES.
ENDLOOP.
ENDFORM. " assign_colors
--
FORM COUNT .
LOOP AT MESSAGES.
CASE MESSAGES-MSGTYP.
WHEN 'E'.
ADD 1 TO WK_FAILURE.
WHEN 'S'.
ADD 1 TO WK_SUCCESS.
ENDCASE.
ENDLOOP.
ENDFORM. " COUNT
--
FORM ALV .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_BACKGROUND_ID = 'ALV_BACKGROUND'
IS_LAYOUT = WK_LAYOUT
IT_FIELDCAT = ALVFLD[]
IT_EVENTS = V_EVENTS[]
TABLES
T_OUTTAB = MESSAGES
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " ALV
--
FORM FETCH_FROM_FLAT_FILE .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1 "From 1st Column
I_BEGIN_ROW = 2 "From 2nd row
I_END_COL = 7 "Till &th Column
I_END_ROW = 65000 "Till Row
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. " FETCH_FROM_FLAT_FILE
INCLUDE***************
***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) 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.
2007 Jul 21 10:51 AM
Hi,
u uploaded data in database successfully.but u want to display the same sales order no on execution of bdc report . put one write statement with sales order no field in internal table loop and endloop.
2007 Jul 21 11:34 AM
Hi rocky,
as we all know, bdc technique is obsolete, slow and unsafe.
OK, many people just don't know how to use BAPI or IDoc.
The last thing, the transaction does, is giving a succes message like 'Order nnn created'.
Check out this message and after call transaction is complete, read the SY-MSGNO and SY_MSGV1 values. SY-MSGNO /SY-MSGID will tell you that the success message has been given, SY_MSGV1 will give you the number.
Regards,
Clemens