We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE:[sap-dev] MM01 Not Working in Background Mode

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from vhietha_darwis on Mar 6 at 3:44 AM
I'm a little bit confused in here since I'm still new in abap. I think I have those BDC_Open_group and it placed in ZBDCRECX3. Here's the code :

*&---*
*& Include ZBDCRECX3 *
*&---*
***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,
NODATA VALUE '/',
SESSION(1) VALUE '',
SMALLLOG(1),
CUPDATE VALUE 'S',
E_GROUP(12),
E_USER(12),
E_KEEP,
E_HDATE LIKE SY-DATUM,
LD_SUCCESS.
* message texts
TABLES: T100.

DATA : BEGIN OF T_MESSTAB OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA : END OF T_MESSTAB.

DATA : BEGIN OF T_LAST_TAB OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA : END OF T_LAST_TAB.

DATA : D_MSGTX LIKE MESSAGE-MSGTX.

RANGES : R_MSGTYP FOR BDCMSGCOLL-MSGTYP,
R_MSGID FOR BDCMSGCOLL-MSGID,
R_MSGNR FOR BDCMSGCOLL-MSGNR.

**---*
** 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).
* ENDIF.
* ENDIF.
*ENDFORM.


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

*---*
* 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.
****** T_REPORT-name1_008 = RECORD-NAME1_008.
****** T_REPORT-TXT50_005 = RECORD-TXT50_005.
T_REPORT-MSGTX = L_MSTRING(250).
COLLECT T_REPORT.
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. "BDC_TRANSACTION

Once again thank you stefan.
Vita

---------------Original Message---------------
From: Stefan Vermeulen
Sent: Thursday, March 06, 2014 3:16 AM
Subject: MM01 Not Working in Background Mode

Hi Vita D,
Guess your Batch-Routines are in either
INCLUDE ZSDUPLCEK. or
INCLUDE ZHRU_TOP.

Please check, if there's an option to open a BDC_Insert and a BDC_Open in there. It's quite easy to make a Batch Folder within your coding, and it might help you find the problem when processed in Background:

Instead of perform BDC_Transaction....
use something like:

call function 'BDC_INSERT'
exporting
TCode = Transakt " <--- Transaction-Code - here MM01
tables
DynproTab = XBdcdata <-- The table you generated with BDC_Dynpro and perform BDC_Field
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7.

and insert a:
call function 'BDC_OPEN_GROUP'
exporting
client = SY-Mandt
group = VGroup
user = SY-UName.

when the first record is processed at:
LOOP AT RECORD.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.

(meaning: if sy-TabIx = 1. call function.... endif.)

at the end of that loop:
if sy-SubRC eq 0.
call function 'BDC_CLOSE_GROUP'.
endif. " sy-SubRC eq 0.




by doing so you generate a batch-Folder, which you can see in SM35 and process there. You'll be able to see the Batchinput data, see error-messages after running it etc.

Alternative:
within the "form BDC_Transaction"
(it's within the includes as mentioned above)
check if the coding is similar like:

call transaction transakt
using xbdcdata
mode p_hellkz " A = anzeigen, e = dunkel
messages into xMessTab. <<<<---- that's the important part

Afterwards you'll have the messages generated from MM01 within your xMessTab, you can printout any warnings and errors and see if there are some hints within.

Please check if you get any messages / warnings which will give you a hint about the problem. If you can't help yourself, reply again here.

Stefan

 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2014 Ziff Davis, Inc. and message author.
Ziff Davis, Inc. 28 E 28th Street New York, NY 10016
vhietha_darwis  

Programmer/Developer - Software
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Have a technical question? Need to find IT solutions? Ask your peers in the Toolbox for IT community.

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language