Work Cited: Rossi,Sandra. (Sep 2011). “Batch Input FAQ”.SAP Community Network. Retrieved 18 Dec 2015 from http://wiki.scn.sap.com/wiki/display/ABAP/Batch+Input+FAQ |
Concepts
Note: Batch input sessions have other functions not listed here (like keep session, etc.) because we just discuss of the BDC technology here. |
•LSMW is a loading tool provided by SAP where ABAP code is automatically generated based on the entered rules, and where the loading method can be BI session (either based on a LSMW recording or on a standard batch input program), BAPI/IDoc or standard direct input program. •LSMW is not able to generate a CTU program, only a BI session. •You can enter custom ABAP in LSMW without need of a developer license, while you need one for writing a "BDC" ABAP program. •LSMW is generally for standard SAP applications, while BDC is mainly for any customized application •The LSMW recorder is much simplified when compared to the SHDB recorder: it always start with default options (update mode A, no default size, use BDC mode (SY-BINPT is 'X'), do not simulate background mode (SY-BATCH is space), and SY-CALLD is set to 'X'). •LSMW recordings can't be migrated to SHDB recordings and vice versa. •In LSMW recording, BDC_OKCODE and BDC_CURSOR fields cannot be edited, and you can't delete or add screens. |
Recording (SHDB)
Using transaction SHDB it is possible to record transactions as well as create skeleton programs that contain all the necessary code for creating batch input sessions. |
There was probably a COMMIT WORK. By default, the recording stops after COMMIT WORK (for more information, read Note 24141 - Program terminates on COMMIT WORK). When you start the recording, you have a checkbox "not possible, but anyway it makes no sense to transport them: the recordings have no vocation to remain in the system, and are usually converted into programs or function modules, which are cross-client. |
1.Display the recording 2.There is a button to export to a file on your presentation server 3.Create a recording without transaction code and without starting the recorder, a button to import is then displayed |
It's not possible, but anyway it makes no sense to transport them: the recordings have no vocation to remain in the system, and are usually converted into programs or function modules, which are cross-client. |
It works the same as CTU with Display Mode "A", but it's surrounded by kernel calls to SET_TRANS_VAR for activating and deactivating the recording: among other things, before CTU, there are call 'SET_TRANS_VAR' id 'RECORDING' field 'X' and CALL 'SET_TRANS_VAR' ID 'ACTIV' FIELD 'X', and after CTU, there is call 'SET_TRANS_VAR' id 'RECORDING' field ' '. The main function module for recording is BDC_RECORD_TRANSACTION, which returns the BDC data. The SHDB recorder records the BDC data into APQI and APQD tables. |
It is available when you record a transaction. Refer to the Display mode chapter in Batch Input - BDC. |
Content of BDC data
First line must always be the screen identification. program dynpro dynbegin |
BDC_SUBSCR is a technical field name in lines of the BDC data. The field value is the concatenation of subscreen program name (40 characters), subscreen dynpro number (4 digits), and subscreen name in the calling dynpro (30 characters). |
It may contain 3 kind of values: •A field name: MARA-MATNR (if several fields have the same name in the outer dynpro, the BDC_SUBSCR line is needed) •A field name followed by a row number between parentheses, indicating a field in a table control or step loop (see FAQ about table control scrolling below): MARA-MATNR(01) •Coordinates in a list (row/column): 07/04 (row 7, column 4) |
You noticed that the SHDB recorder generates lines containing BDC_CURSOR in the BDC data (which are used to position the cursor, as the name suggests), but you think you don't need them because you don't use contextual actions based on the cursor position and you think that they pollute the BDC data. So you decided to remove them systematically when the cursor is not important. You must be careful while doing that, as you may not be aware that the cursor position is required in these 2 situations (though they are relatively rare): •when there are buttons inside screens and the BDC_OKCODE line is not specified (see Note 13882 - Handling of POPUP_TO_CONFIRM in batch input) •when the screen doesn't contain any input fields, active checkboxes or selection fields, and when the cursor position is checked (see Note 33319 - Batch input: Backgr. runs diff. than in the dialog). |
Influencing the execution
This is a structure defined in the ABAP Dictionary (SE11) that must be used to declare the type of variable after the OPTIONS FROM keyword of CALL TRANSACTION ... USING ... ("CTU") statement. It contains many fields to influence the CTU behavior. For more information, refer to ABAP documentation - CALL TRANSACTION - bdc_options. CALL TRANSACTION 'SM04' USING lt_bdcdata MODE 'N' UPDATE 'S'. is the same as: DATA ls_ctu_params TYPE ctu_params. ls_ctu_params-dismode = 'N'. ls_ctu_params-updmode = 'S'. CALL TRANSACTION 'SM04' USING lt_bdcdata OPTIONS FROM ls_ctu_params. |
Refer to Batch Input - BDC. |
Refer to Batch Input - BDC. |
Refer to the Display mode chapter in Batch Input - BDC. |
These commands are only available in foreground mode (A or E), and they are not available in CTU. They are also accessible via the menu under System -> Services -> Batch Input. See also SAP Library - Managing Batch Input Sessions - Correcting a Session. |
The expert mode is a checkbox which is displayed on the launch popup screen of the BI sessions. |
When you tick that checkbox when you run a BI session in A or E mode from SM35 transaction, or using LOGALL parameter of RSBDCSUB program, there is the following behavior: •The I messages are not written to the log •The W messages are written to the log •The S messages are not written to the log, except the last one provided it's the last message sent, and it's sent after the last screen (PAI or later, but before COMMIT WORK of course as a BI session can't continue). For example, if a I message is sent after the S message, then the S message is not written. •If no S message has been written to the log, SAP writes the S00355 message: "Transaction was processed successfully". Notes: •This checkbox is not related to the "Details" checkbox that you can tick when you display a BI session log. •This information is taken from this SDN discussion. |
There is a checkbox "Details", which allows to see messages 00162 (>>>>>>>>>>> & &) and 00368 (&1 &2 ) or not. |
This function is only available with BI sessions. Changes are automatically recorded into the log (since Note 604066 - Batch input: Logging of OK code changes). When you display it, you must tick the checkbox "Details" to display these messages (since Note 678979 - Batch input: allow log details to be hidden). |
NOBINPT option (in CTU_PARAMS) is used to execute the CTU with SY-BINPT system variable set to blank ("X" is the CTU default), as interactively. Don't be mistaken by its name ("no batch input"), it's completely allowed to run a batch input with "no batch input" mode, though the played transaction may have then restricted functions. The SY-BINPT variable is usually checked by the application when some of its user interfaces cannot be recorded and played using the BDC technology (*), and when this application is designed to work with BDC. If it runs in batch input (it usually knows it by testing SY-BINPT), it proposes another display mode or other function codes that are compatible with BDC. Sometimes, strangely, a played transaction may work better by forcing SY-BINPT to space (using NOBINPT = "X" option). (*) Especially the control framework (CNDP_ERROR) and table control scrolling (see FAQs below) |
Troubleshooting the execution
You run a transaction with the same actions in 2 ways (from SAP menu or BDC, dialog or background, etc.), but they don't behave identically. There can be any symptoms. You checked all other FAQs but you still don't understand what the issue is. The following table shows all the possibilities that can be cause of a different behavior. Real examples, how to use the table: •Example 1: the CTU works when you execute it interactively with E display mode, but doesn't work anymore when you use N display mode, let's say a screen is displayed without error message which means screen is not expected. •By reading the table, we see that the following are excluded: #1 because SY-BINPT is 'X' in both E and N display mode, #2 because SY-BATCH is always space in both display modes, #3 because SY-CALLD is "X" in both cases, etc. But these ones can be the culprits: #4, #8, #9. •Example 2: when you run the transaction via CTU (with default options), it looks like different (text editor is ugly, old-fashioned) than when you run the transaction normally from the SAP menu. •We see that #1 is a good culprit as SY-BINPT is "X" when CTU is run, but it is space when run from the SAP menu. #3 (SY-CALLD) could also be the culprit. |
There are 2 buttons "Session overview" which restarts SM35 and "Exit batch input" which displays the SAP menu. |
Not all screens can be recorded, especially when they contain interactive lists or controls (control framework). For more information, see note 311440 - batch input and controls. The only solution is to modify the program so that it doesn't display the control when the transaction is run (see FAQ "How to know programmatically if the transaction is run via CTU or BI session or none?"). |
Only messages sent with MESSAGE are collected in BDCMSGCOLL (CTU) or logged (BI), except if: •MESSAGE is used with one of these additions (the message is handled internally by the program): •MESSAGE ... INTO ... •MESSAGE ... RAISING ... •Those sent inside a function module (and in its called procedures) called with EXCEPTIONS error_message = <any> are also not collected. •or if the message makes the program abort or dump. Situations are explained here: SAP Library - Screen programming - Message Processing •In A and E (and D/H) display mode, messages 00344 ("No batch input data for screen & &") are not displayed and not returned (except for BI session with expert mode activated). •In BI, messages 00355 are not returned if the BI session is not run with "Detailed log" •There is also the case where the message is returned, but not displayed: when you display the BI session log, messages 00162 and 00368 are not displayed if you didn't tick the "Details" checkbox A frequent issue is that messages are output by a method like like ALV, table control, etc., that is not the standard message output (i.e. either the message specific modal dialog box or the status bar of the screen). To do so, they are handled internally by the program, and so can't be collected into BDCMSGCOLL internal table. The only solution is to change the way they are handled inside the called transaction, as explained above. For example, the program could test SY-BINPT to choose how messages are to be displayed, either ALV or as explained above. |
There is probably an error 00344 ("No batch input data for screen & &"), but it is not displayed in these modes (only in display modes N/P, or when it is run using a BI session and expert mode activated). That happens because the screen displayed is not the same program or number than the next screen defined in the BDC data. Note that if the end of BDC data is reached, the last screen remains displayed when the display mode is E, while the transaction terminates when the display mode is A. |
Either it's because of an error 00344. See question "Why the BDC in display mode A or E stops at a screen without any message at all? (in mode A, OK code dialog box disappears)" above. |
First of all, dates must be entered in the external format (same way as a user does), for example MM/DD/YYYY if the user is from USA (more precisely, the user has date format "2" in the "Defaults" screen tab of SU01 transaction). You can for example use this code to convert a date variable from internal to external format:
The screen_date_field variable will contain 12/31/2010 for the USA user. Before 7.0, you had to run the CTU and BI sessions with a user with exactly the same date format than the one used in the BDC data. Since 7.0, when you create a BI session (CTU still works as before), you can indicate which date format is used in the whole BI session, and you'll be able to execute it under any user, because SAP will convert the format of every date field when the BI session is run. The date format can be indicated when you create a BI session from SHDB, or from BDC_OPEN_GROUP function module DATFM parameter. If the DATFM parameter value is "%" (default), SAP will use the user's date format. |
In CTU, an obvious answer is that you forgot to empty the BDC data internal table (using REFRESH statement) between each CALL TRANSACTION! |
You must suffix the field name with the line number between parentheses. If the screen field name is BSEG-BUZEI, and you want to fill it in the second line, then you must enter BSEG-BUZEI(2). |
•Usually (*), the recorder records the Enter key (/00) when you scroll, so the system does not scroll when you play the recording (BDC). This is a technical restriction. •Workaround: the transaction may also provide a function code (not always displayed as menu or button, so we sometimes need to look at SAP notes or search in ABAP code yourself) to: •insert a line at the beginning or at the end of the table control, and display the table control with that line at the top, so that you can refer each field of it using FIELDNAME(01). •position the table control at a given line (a popup is usually displayed to enter the line number or the key. Unfortunately, it varies for every transaction), and display the table control with that line at the top. •See for example Note 187946 - No positioning on PRT overview in routing. (*) If you are "lucky", the recorder may record something else than /00, in that case the scroll will work in BDC. How to assign function codes to scroll keys: create a GUI status of type "Dialog", where you assign a function code to the scroll keys in the system status bar, and assign the GUI status to the screen (SET PF-STATUS). Notes: •The function codes to scroll don't need to be systematically P+, P-, P++, P--, that's only a naming convention •Contrary to what is often said, the function codes P+, P-, P++, P--, won't scroll at all if they are not defined as the scroll keys in the GUI status, and handled in the program. |
There are 2 possibilities: •You tried to fill a field in a line of a table control that is not displayed yet: you need to scroll the list to reach that line. •You executed the BDC with the standard default size (22 lines * 84 columns). When the table control has attribute Vertical Resizing allowed, then the number of rows may be reduced up to which makes the table control appear with less lines than when you see the screen in normal mode. |
You probably used the include BDCRECX1 and the dump occurs at statement "IF FVAL <> NODATA." in form BDC_FIELD. It's because you passed a N type field (or F, I, etc.) to the FVAL parameter, and SAP compares it to NODATA which is C type, so it tries to convert NODATA (value "/" by default) to a number to be able to compare them, and dumps because / is not a number. |
Special development
Use this ABAP program: Get log of batch input session |
If there was no error, then data was written and terminated by a commit work, so it's not possible. Try to find another way to update database which doesn't perform any commit (use for example a BAPI, or an IDoc message that allows processing by packet). |
Yes, by using the S or L update mode. |
If you want to run a normal report which outputs a list or does a background processing (updates database or generates a file, etc.), you may simply use SUBMIT ... AND RETURN statement. By default, selection screen is not displayed, and you fill the parameters using WITH keyword, and you may use EXPORTING LIST TO MEMORY to get the result into an internal table variable. |
You can use CALL TRANSACTION ... AND SKIP FIRST SCREEN without USING, but you can't use it with CALL TRANSACTION ... USING. |
When the user saves a standard object, it may be required to create or update another business object at the same time, using BDC (remember that you should prefer to use BAPIs if available). Read the solution based on tRFC in that thread in SDN (http://forums.sdn.sap.com/thread.jspa?messageID=9371113). |
It can be entered using normal batch input, but this link already contains the required code to do it, in a very easy way, just provide the selection table and that's it : Fill SELECT-OPTIONS in BDCDATA |
Miscellaneous questions
The programs are usually indicated in the documentation or in SPRO transaction. You may also find a list of them in LSMW transaction, in first step ("Maintain object attributes"). |
Yes, since SAPGUI 6.10, see Note 453557 - Batch input: Hiding OK code dialog box |
First of all, NODATA is not really part of the BDC technology, but it's a smart trick used by data input programs (using BDC, direct input, or any other technologies) where data is provided in flat or CSV-like files. NODATA is the name of a character that is used to say "don't fill the field if it contains NODATA". We could think that fields with empty value should not be filled, but "unfortunately" it is often needed to blank out fields. NODATA is used to be "/" in the BDC technology (when you generate a program or function module from SHDB transaction), but you can use any value that is never used as a real value. You'll find more information in SAP Library - Batch Input - NODATA. |