Goods Movements with the Batch-Input InterfaceLast saved: 21.02.2001 (JKr) This document describes issues related to the posting of goods movements using batch-input. It concentrates on the standard program RM07MMBL to create a batch session out of a sequential file. Program RM07RRES for reservations has emerged by copying and follows the same principles. Additionally general hints related to batch-inputs are given. Goods Movements....................................................................................................................................................1 with the.....................................................................................................................................................................1 Batch-Input Interface................................................................................................................................................1 1 Overview................................................................................................................................................................2 2 Data structure.........................................................................................................................................................2 3 Data source.............................................................................................................................................................3 4 Creation of the batch-session with RM07MMBL..................................................................................................4 5 Description of the screen sequence........................................................................................................................6 6 Working with batch-input sessions........................................................................................................................7 7 Using RM07MMBL for own purposes..................................................................................................................9 8 Manually created batch-sessions (SHDB, Batch-Input Recorder).......................................................................10 9 Miscellaneous issues............................................................................................................................................10 Goods Movements with the Batch-Input Interface Page 1/11 BLDAT. A batch-input session is a sequence of keystrokes and data to be entered into fields on screens. A correction of this issue is not possible due to compatibility with the installed base. The program RM07MMBL decides by change detection of header relevant information when to start a new material document. To demonstrate the necessary file structure. Behind the posting date there is a space. MB31 (goods receipt for production order) and MB11 (other movements).1 Overview Batch-Input is a method to operate SAP transactions in an automated way. FRBNR. The file on the application server contains multiple rows of data in this flat format. The posting logic of the underlying program is not affected. even the header data. definition of structure WEWA_HEADER. It remains blank. This is the content for field WEVER. material master). This sessions contains two transactions MB11 (two because the date changed). BKTXT.. The data for this program usually are read from a file placed on the filesystem of the application server and are used to create a batch-session to post the movements. XABLN (field LDEST is never used) as genuine header fields and BWART. Field which cause a material document change are given in RM07MMBL. LIFNR as position dependent fields which also create a new material document. this is just for demonstration): Field MAPPE TCODE BLDAT BUDAT WEVER BWART MATNR ERFMG ERFME . BUDAT. WEVER. Our program checks for the field to be NOT INITIAL before writing it to screen. This program RM07MMBL operates on the transactions MB01 (goods receipt for purchase order). The first transaction will contain two items. let’s assume the structure BMSEG would look like this (in reality it’s different. SAP provides a standard program to post goods movements using batch-input.g. Even if the basis documentation states that unused fields have to be filled with a "/". This makes it impossible for our program to clear prefilled data on the screen. Page 2/11 Goods Movements with the Batch-Input Interface . Unused fields have to stay blank.5 56 1 L ST L This file will create a batch-session named "SESSION1". XBLNR.. Type CHAR CHAR DATS DATS CHAR CHAR CHAR CHAR UNIT Length 12 20 8 8 1 3 18 17 3 Description Session name Transaction code Document date Posting date Print version Movement type Material number Quantity Unit Each line in the file needs to have this structure (technically the line read from file is just MOVE-ed to an internal structure of type BMSEG. MTSNR. There is no hierarchical structure as in other components (e. Remarks: • • The four character transaction code MB11 is followed by 16 spaces as the field BMSEG-TCODE is defined to have length 20. unless the program explicitly wishes to react differently (using SY-BINPT as indicator for batch-input operation). In contrary to what is generally expected for the input format. there also is no "no data"-symbol. SESSION1 SESSION1 SESSION1 MB11 MB11 MB11 2000123120001231 561JKMAT 2000123120001231 561QLAROH 2000123020001230 501JKMAT 10. Currently these are: TCODE. All data are contained in this single structure. 2 Data structure The movement data which are to be posted have to be in the layout of the DDIC-structure BMSEG. this is not the case for our program. it is not possible to maintain data in the supportpackage systems (this applies to the P. "/tmp/mmgoods" and the application server is a windows platform. simply because it violates the filename rules.1 From the logical filename to the physical filename The file is addressed in RM07MMBL with a "logical filename".2 Creating test data To view the contents of the sequential file which RM07MMBL will process and to manipulate it. 3. which is dependent on the operating system of the application server. fields should only be appended. the batch-session will send DDMMYYYY to the screen. This is a difference to the convention for IDoc-data. In the "Definition of logical files. Check the (obsolete) table FILENAME for the given logical filename. even if the operating system has been changed. Example: If the user setting is DD.g. the system returns this old filename immediately. Result: If the table is filled with e. It is a fact that the fields in CI_COBL are not evaluated by RM07MMBL and therefore this include is completely superfluous. The "data transfer object" is 110 for goods movements (and 120 for reservations). In the physical pathname. Here. which defaults to MM_INVENTORY_MANAGEMENT_GOODS_MOVEMENT. i. This can be determined in "System Status". basis converts these data to a representation according to the user settings for the date format (but omitting the separators). During the creation of the session. So creating a personal test file is impossible without using SE16. To see which file is really accessed with this name. this probably will be "C:\TEMP\".YYYY. and nothing to be found in the R/3 database. This might result in error 00 064 (Invalid date). The quantity has to be specified in the same format which has to be entered on screen. Note that the session cannot be played if the user playing the session has a different setting. Before.g. For WINDOWS_NT. YYYYMMDD. 3. If this setting is still present. for UNIX "/tmp/".as to the U-systems). a file format (ASC). If the field FILEEXTERN is filled. client independent" the logical filename is assigned a description. variables may be used.MM. a working area (MM. it was possible to assign a physical filename directly to the logical filename. This transaction allows to create.• Date fields are always to be given in internal representation. FILENAME will be replaced by "mmgoods" and "P=DIR_TEMP" will be replaced by the temporary path filename. Behind the "logical path" an assignment to a physical path can be found. As transaction FILE operates on client independent tables. Here.e. the transaction SXDA (from release 4. the same rules as for BAPI-structures should be applied. without using the logical path. the comma is the decimal separator. Goods Movements with the Batch-Input Interface Page 3/11 . which should be avoided.6 it is SXDB) is very recommendable. if the user setting is MM/DD/YYYY. The structure BMSEG also contains the customer include CI_COBL. which the systems administrator has to set up. The phrase "sequential file" just means a real file on the filesystem of the computer. e. do not know what this is used for) and finally the "logical path". change and view the file contents. 3 Data source The data to be processed by RM07MMBL need to be placed in a "sequential file" on the application server where RM07MMBL is started. the batch-session will send MMDDYYYY to screen. in U9B the path TMP evaluates for WINDOWS_NT to "<P=DIR_TEMP>\<FILENAME>". Attention: There is an exception to the just described rules: Some time ago the file handling has been changed. this file cannot be accessed. As the insertion of a field will invalidate all existing files which use fields on the right-hand side of this field. a physical filename (usually "mmgoods". the customizing in transaction FILE needs to be evaluated. • For the structure BMSEG. its contents will be returned. 1 Initial screen The report RM07MMBL can be started from within SXDA/SXDB or directly. After completion of a line item. This will return to the file-edit screen. In the edit mode. press "Transfer data". the structure of BMSEG is shown: The data have to be entered in the form how they would be entered on screen. In the edit mode. it is possible to edit.3 Files are server dependent Please note that the created/modified file is located on the file system of the application server the operations have been executed on. 3. delete and copy lines. 4 Creation of the batch-session with RM07MMBL 4. view. Goods Movements with the Batch-Input Interface Page 4/11 . where the file can be saved. Working on another server. it is automatically prefilled with a single line whose data are derived from some fixed settings. it might be that the data are completely different. the transaction allows a manipulation of the file: After placing the cursor.When creating a file. This is useful to evaluate the session log which contains all messages issued during the processing and especially the created material numbers (which are published as S-messages). the conditions for a change of session and/or document are checked. MB11 and MB31 which are processed in forms POSITION_MBxx. This table. See 3. this internal table is processed line by line using form MAPPE_AUFBAUEN. the logical file is read and copied into the internal table YWEWA. RM07MMBL will create a new document. HSDAT and VFDAT is dangerous nonsense (in my opinion). This parameter is routed through to the form MAPPE_OEFFNEN in a totally funny way. If exceeded. User name in document: The name of the user who will be in the batch-session. It causes the session not to be deleted after successful posting. the report will show a list of the created session from which one may branch directly to SM35. • • • 4. the single dynpros are created and filled with the data from YWEWA. In Form MAPPE_AUFBAUEN. The method is obsolete and incomplete and should not be used any more. Double clicking in a session will start SM35 where the session can be processed (6. RM07MMBL can handle the transaction codes MB01. the document and session are closed and the protocol is issued. Here. Finally. Test data: If this flag is set. The coding with MHDAT. The authority-checks during playing of the session will be done using this name. together with a separate maintenance view. Note that files are application server dependent.The parameters are: • • • Name of logical file: The file which this report will work on. number of items: Maximum number of line positions in a material document. Hold processed sessions: A control flag which is transferred to the session. were the predecessors of the capabilities of SXDA/SXDB.3 Output screen The protocol shows a list of the created sessions. Then the session if opened if necessary and the screens are processed.2 Program flow At the event START-OF-SELECTION. which is used during the rest of the program. RM07MMBL does not read the logical file. In event END-OF-SELECTION. As a general rule. Max.1). an entry in the session table is done if the value in YWEWA is not initial. 4. Goods Movements with the Batch-Input Interface Page 5/11 . Be surprised! Issue log: After having created the session.3. but tries to overwrite it with data it retrieves from table T159A. Movement type. SAPMM07M 1403 BDC_OKCODE /12 The system now shows returns to the detail screen (same position as before because popup 1403 did not press "New item". only the data relevant for the entire document are filled. SAPMM07M 0410 BDC_OKCODE /12 As a result. SAPMM07M 0400 MKPF-BUDAT 22082000 MKPF-BLDAT 22082000 RM07M-XNUVR X BDC_OKCODE VOR With the special OK-Code VOR (in the menu: Edit/Default values…) it brings up a popup to set the movement type. … But before this popup is sent. the accounting screen will appear. SAPLKACB 0002 BDC_OKCODE /08 Now the popup is there and as there is no new position. 5. The last code is F11 (post). It is not programmed by us but an external component. we have a look at a simple stock uploading procedure. This is a situation not suitable for batch-input. It will never work with the overview list (where several items can be entered on the same screen) because table-controls and step-loops cannot be handled by batch-input. the system is in the screen where all items are shown ready to post. As every line entered in the overview screens process the detail screen anyway (in dark-mode). it is necessary to press a button on the accounting screen to see all necessary fields. storage location… SAPMM07M 1403 RM07M-BWARTWA 561 RM07M-WERKS 0001 RM07M-LGORT 0001 BDC_OKCODE /08 The OK-Code /08 (meaning = key F8) is "New item" brings the system directly to the detail screen of a new position (the list screen is omitted). plant and storage location do not belong to them. The answer is a checkbox on the initial screen of the goods movement transactions which is visible only if SY-BINPT = 'X' and defaults to 'X': It's name is RM07M-XFULL. plant. which will bring up the popup for a new set of movement type. plant.2 Handling of the accounting screen The accounting screen (by historical reasons also called the "coding block") is the screen area used to enter the accounting information. SAPMM07M 0410 MSEG-MATNR JKMAT MSEG-WERKS 0001 MSEG-LGORT 0001 MSEG-ERFMG 5 MSEG-ERFME ST BDC_OKCODE VOR Every detail screen data entry is ended with the OK-Code VOR. It is finished with F12 (Cancel). It's design and field collection depends on decisions of CO. It is filled whatever accounting data are available in YWEWA and then confirmed with F8. On the initial screen. it is terminated with F12. this is no performance loss.1 Example To give an overview over the general screen sequence. Goods Movements with the Batch-Input Interface Page 6/11 .5 Description of the screen sequence The screen sequence which RM07MMBL uses is quite different from online processing. SAPMM07M 0420 BDC_OKCODE /11 5. For some fields. The communication structure BMSEG contains field SERNR. but will appear as popup with all available accounting fields. Automatic lines are unexpected in this way. Note 305635: The indicator NO_COBL_BLOC..1 Session overview In transaction SM35. I do not know. As long as no accounting data are to be entered.4 Serial numbers A serialized material causes SAPMM07M to call function modules from component LO-MD-SM which sends a popup to enter serial numbers. this note can make RM07MMBL work for all automatic line problems. maybe setting this flag might be a nice idea.3 Automatic lines (subcontracting. . batch-input sessions are shown. It cannot react on unexpected events. It must not be said that this solution is extremely unstable. If errors with the accounting screen appear and there are no accounting data to be filled. after the 543) which disturbs the screen sequence. as their appearance is unknown to the batch-session (it cannot distinguish between normal PO's and subcontracting PO's). i. too.If this is set (as is the default case in batch-input). the accounting screen will not be visible as subscreen. RM07MMBL does not fill data for the accounting screen. It is impossible to give advice when to set it or not (I cannot understand what the thoughts might have been). Much better is the approach from. Maybe a new note should be created. so that RM07MMBL can freely fill its data into the popup (SAPLKACB/0002). BMSEG contains a field NO_CO_BLOC. generally such business processes are not supported by RM07MMBL.g. because optional serialization is not supported. Goods Movements with the Batch-Input Interface Page 7/11 . and as long as the detail processing goes through without errors.. Therefore. production date.). which is sent automatically after each position (also e. RM07MMBL checks whether the material is serial number managed (direct access to MARC after first converting the material number from external to internal representation) and then checking the serial number profile in table T377 for entry MMSL with activity 03 (mandatory serialization). It is also absolutely possible that this flag has been introduced for a single special customer problem which either was no error at all or is resolved otherwise in the meantime. the number of components to be processed is unknown and RM07MMBL does not provide mechanisms to provide data for the components (hierarchical data structure). To make it even more complicated. two workaround-solutions (modification) have been developed: • Note 40176: This note addressed subcontracting POs by trying to find out how many components are proposed from MM-PUR and pressing the "Continue"-button on the accounting-screen popup this many times. If this is set. I consider this checks as superfluous and even incorrect. 5.e. introduced with note 67657 (whose meaning in this note could not be understood) is reused in order to skip the batch-input behavior of the accounting-screen completely. it does not send a popup. The most critical part here is the accounting screen. Another case are missing data for the components (batch. In the course of time. but is classically embedded into our screens. But instead of simply expecting the popup if this field is filled (and that way laying the responsibility onto the creator if the sequential file to know whether a material is serialized). This is an unexpected screen sequence.. 6 Working with batch-input sessions 6. • 5.. retail) The batch-input session is executed totally blind by the system. This standard size is necessary to ensure a predictable number of table-control or step-loop lines for transactions which use these elements.2 Displaying session contents In SM35. use function "Session Print session contents". The regularly flagged indicator "Dynpro standard size" reduces the size of the screen to the fixed size of 22 lines and 84 columns.3 Simulating Batch-Input for SAPMM07M To make SAPMM07M believe that a batch-input session is being played (giving full access to the usually dark checkbox. One may send this data to spool only without printing immediately to view it or to download it to the local PC (when working in remote systems). the filled fields and the OK-codes which are executed. they can be executed. the flag SYBINPT must be set at the earliest possible moment during the transaction MBxx. To get a better overview. Report MBDEBUG can activate a breakpoint here. in dark mode with stop in error case or completely in background. This can be done in online mode (useful for test purposes). the "Analysis"-button allows to view the single transactions and their screens. The resulting list shows all screens. Goods Movements with the Batch-Input Interface Page 8/11 .From here. to some otherwise deactivated menu functions and to the fun with the accounting screen). This can happen in module TRANSAKTIONS_INIT(MM07MO00). 6. 6.3) to manually play a session. so that this list can be used together with the batch-input simulation (see 6. 5 Update strategy Batch-input sessions use the standard update process (unless the application coding explicitly uses SET UPDATE TASK LOCAL). APPEND ls_bmseg TO lt_bmseg.e. It terminates the current transaction (marking it as faulty so it can be reprocessed) and the batch-session immediately moves forward to the next transaction in the session. RM07MMBL can be used to create a batch session to post the documents.1). the flag XKEEP (Hold processed sessions) is not evaluated when working with memory data.g. i. The advantage is that batch-input provides a sophisticated mechanism for error handling and ensures that each transaction is posted exactly once. "Demonstration! ls_bmseg-bktxt = sy-index. but they do it in synchronous mode. As another consequence errors in the update process (update termination) are logged in the session log. lt_bmseg TYPE STANDARD TABLE OF bmseg. Note: Due to a program error (?) in RM07MMBL. A submitted RM07MMBL reads this memory segment and if something is found. a demand which requires a lot of handicraft work to realize in an own program using the function modules. This is useful in order to avoid all update processes to be occupied by update requests from a single batch-input session being executed. "Internal representation will do ls_bmseg-bldat = sy-datum. 7. START-OF-SELECTION.6. when correcting inconsistencies). the logical file is not accessed and the report uses the internal YWEWA. entering /N in the command code field does not have the desired result. i.1 Example REPORT zkremp_batch. didn’t they. The data to be posted have to be filled into an internal table of structure BMSEG and exported to memory id CPIC_YWEWA with the name YWEWA. They really created crazy programs. 6. after the COMMIT WORK the session waits until the posting is completed. the transactions whose update failed are marked as faulty and can be reprocessed. ls_bmseg-mappe = 'KREMP1'.4 Terminating sessions When executing a batch-input session. It also avoids locking problems if identical business objects are accessed in short order. DATA: ls_bmseg TYPE bmseg. Goods Movements with the Batch-Input Interface Page 9/11 . 7 Using RM07MMBL for own purposes In cases where it is necessary to post a large number of goods movements which cannot or should not be done with a program using MB_CREATE_GOODS_MOVEMENT or BAPI_GOODSMVT_CREATE (e. ENDDO. In a multi-transaction session is does not work. DO 10 TIMES.e. It terminates the entire session. ls_bmseg-matnr = 'JKMAT'. "Forces new document! ls_bmseg-bwart = '561'. Instead. ls_bmseg-lgort = '0001'. * These names are mandatory: * XXXXX XXXXXXXXXX This program creates a batch-input session which posts 10 material documents. use OK-code /BEND. ls_bmseg-budat = sy-datum. ls_bmseg-werks = '0001'. ls_bmseg-tcode = 'MB11'. The status management of the batch-input processor ensures that only a COMMIT WORK causes a transaction to be marked successfully posted (see also 9. ls_bmseg-erfmg = sy-index. Example: A goods movement with transaction MB11 is recorded. which is definitively wrong. material. The date is entered and the document posted.”. The normal program flow of MBxx only has a single COMMIT WORK. quantity and storage location are entered. 9 Miscellaneous issues 9. This method is useful to create a mass batch-input for other transactions than MBxx. A way described by BASIS is to use the dynpro-trace to identify the additional COMMIT WORK’s. the basis message 00 355 is issued (transaction successfully finished).1 Entries made on the detail screen in error conditions Due to the complicated screen handling of MM-IM. Press “Change”. Before playing the session. If an error occurs on one of these screens. As an example please see note 307007 from CO-PA. On the overview screen (SAPMM07M/0421). but this is not in our hands. and it will not happen once again because now the generation has been done. The correct behavior is to terminate processing of such routines in batch mode. the system jumps to the detail screen (SAPMM07M/0410) and requests this input. After entering movement type and plant on the first screen. the session is “successfully” posted. 8 Manually created batch-sessions (SHDB. 8. This is no program error. Because the material requires the input of an expiry date. In the created session. If no message at all has been sent up to this point. There is no way to set a break-point for “COMMIT WORK outside MM-IM coding” or to activate a COMMIT-lock in our coding. The batch-recorder does not see these dynpros (see note 329953). The generally recommended way to create batch-input sessions avoids the overview screen to enter and correct data and always uses the detail screens (the button "Copy+Detail" is useful here). the detail screen is processed in dark mode (SUPPRESS DIALOG). Now the process is marked yellow in SM50. but a handling error which emerges from our coding. As a result. This transaction traces the online execution of a transaction and can create a batch-input session or an ABAP program to create such a session. enter is pressed. Then choose trace level 2 and activate only “Scrn. it can be seen that the batch-recorder noted the expiry date as entered on the overview screen. batch-sessions can be created manually. because one may see the effect only after it has already happened.g. What happened? For all lines on the overview screen. WRITE: 'Finished'. activate the trace for the process which will process the session (if the session is submitted to background. business area. it is possible to create a recording (which is the pre-step of a batch-input session) and create an ABAP program from that recording. It is difficult to find these coding parts. but still believes it is on the overview screen. menu function “Process Trace Active components”.proc. Batch-Input Recorder) With transaction SHDB. However there are components of R/3 which sometimes need to generate coding upon the first movement for a new object (e. This program can then be modified to use another data-source (the generated code has the data from the recording in hard-wired form). The batch-recorder only sees the input of the fields. the error "Field MSEG-MHDAT not present in screen SAPMM07M 0421" is issued. cost calculation) which they finish after coding generation with a commit. As a result. SUBMIT rm07mmbl AND RETURN. 8. basis terminates the dark processing and shows the screen. usually the first work process in order of process number will be selected) in SM50.EXPORT ywewa = lt_bmseg TO MEMORY ID 'CPIC_YWEWA'.1 COMMIT WORK causes incomplete sessions A batch session is finished as soon as the statement COMMIT WORK occurs. Goods Movements with the Batch-Input Interface Page 10/11 . if the session is executed. sessions created with the recorder sometimes cannot be played. but no material document has been created.2 Creating a program body from SHDB With SHDB. Keystrokes to close the message boxes are not part of the session. the new screen (the debugger-screen) causes the batch-input processor to issue the message 00 344 (No batch input data for screen <screen> <dynnr>) is issued. A reprocessing is possible. 9.e. deactivate the trace in the same way by pressing “Default Values Change”. Warnings and I-messages appear when playing a batch-input session in foreground. as soon as the screen sequence arrives at the expected screen. If a batch-input session contains multiple transactions.3 Debugging when playing a batch-input session If the debugger is called (either by /H.After having played the session. The trace file can be evaluated also in SM50 and shows all module calls and also the COMMIT WORK events. Goods Movements with the Batch-Input Interface Page 11/11 . 9. However. but are ignored with respect to the additional operating steps. the next transaction is executed. it is not caught with EXCEPTIONS ERROR_MESSAGE) causes a transaction to be terminated and marked as faulty. by break-point in the source or MBDEBUG). the processing resumes without errors.2 Errors. whereas the indicated screen is the screen of the debugger. warnings and I-messages during batch-input An error-message which is issued on screen (i.
Report "MM Goods Movements With the Batch-Input Interface"