8/27/2019 Bdc Program With Screen Loop In Sap
Table Controls vs Step Loops TABLE CONTROLS TABLE CONTROLS are simply enhanced STEP LOOPS that display data with the look and feel of a table widget in a desktop application. TABLE CONTROLS are always single lines, but can be very long. ( Table control rows are scrollable ). The structure of table controls is different from step loops. STEP LOOP The STEP LOOP are the predecessor of TABLE CONTROL they are used to display tabular data on the screen.
They are repeated sequence of blocks of screen element. In a step loop number of screen elements are combined together to form a loop block. A step loop, as a screen object, is simply a series of field rows that appear as a repeating block.
Related: There are 2 types of step loops: 1) Fixed Size 2) Variable Size. In a fixed size loop the number of loop blocks shown in the screen is fixed,while in case of variable size step loop the number of blocks will change dynamically according to the size of the screen.There could be only one variable step loop per screen and unlimited fixed size step loops per screen. A step loop can extend more than one line on the screen(see Table Control).A vertical scroll bar is automatically created to show step loops on he screen. Step loops have no name. We use LOOP.ENDLOOP to program step loops in a screen in both PBO and PAI. Since the number of loop blocks in variable step loops can change the number of loop blocks at any moment is placed by the system in system field SY-LOOPC and the current step loop pass number is placed in system field SY-STEPL. Loop Type attribute is used to specify the type of step loop and Loop Count attribute is used to specify the number of step loop blocks that will be displayed on the screen at a time.
Step Loop Screen Creation We create step loop in the screen painter( SE51). First we define the screen elements that will be part of the step loop on the screen,they may extend to more than one line.Select all the elements as one group.Goto Edit menu and select Grouping-Step Loop-Define.
To define a step loop as variable or fixed.goto Edit-Grouping-Step Loops-Fix or Variable. To edit the Step Loop click on the border of the block and goto Edit-Grouping-Step Loop here we can use define/undefine(delete)variable fix options. Once created we have to program step loops through screen key word LOOP.ENDLOOP in PBO and PAI as these events are used to transfer back and forth the data from the ABAP program.
STEP LOOP Coding We use two flavours of LOOP. ENDLOOP in screen flow logic to program the step loops.We have to program both in PBO and PAI so that transfer of data can take place between screen and ABAP program. 1) LOOP MODULE filldata ENDLOOP. Here in PBO a module should be called that will transfer the data to the screen fields.
In PAI the module call is not required only the empty LOOP.ENDLOOP will do or we can call a module to write the data to an internal table.In this method there is no automatic scrolling we have to program it in ABAP. 2) LOOP AT inttable INTO wa CURSOR linenumberFROM n1 TO n2 ENDLOOP. Here in PBO a module call is not required to fill the step loop screen fields as the data is copied to the workare wa and from there to screen fields in step loop automatically. INTO wa is not required if we use the inttable declared with a header line.
In PAI the addition AT inttable is also required for automatic scrolling. The parameter CURSOR linenumber which is of TYPE I is used to specify That will be the first to be displayed,it is filled in the ABAP program. But from a programming point of view, TABLE CONTROLS and STEP LOOPS are almost exactly the same.
NOTE: 1) It is preferable to use TABLE CONTROL instead of STEP LOOPS. 2) It is preferable to use LOOP AT inttable instead of plain LOOP.ENDLOOP. Steploop and table contol is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen?
Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction ' ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP') I find a method with which we can determine the number of visible lines on Transaction Screen from our Calling BDC program. Maybe it is useless to you, but I think it will give your some idea. Demo ABAP code has two purposes: 1. How to determine number of visible lines and how to calculate page number; (the 'calpage' routine has been modify to meet general purpose usage) 2. Using field symbol in BDC program, please pay special attention to the difference in Static ASSIGN and Dynamic ASSIGN.
Now I begin to describe the step to implement my method: (I use transaction ' ME21', screen 121 for sample, the method using is Call Transation Using.) Step1: go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop. Then have a look at steploop itselp, one entry of it will occupy two lines. (Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line) Now we have: FixedLine = 9 LoopLine = 2(for table control, LoopLine is always equal to 1) Step2: go to transaction itself( ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input. BDC vs BAPIWhat is the main difference between BAPI and BDC?ttttttBAPItttBDCtttttttttBAPI is used only when it is available for the particular transaction like Delivery Sales.
![]()
LSMWBDC and LSMW are the two data migration techniques (from legacy to SAP). BDC technique is usually done by ABAPers.Batch Data Communication (BDC): BDC(Batch Data Communication) is. How does a loop statement exactly work in SAP? How can we know which table navigate to loop?Suppose we have to fetch data from two different tables and print it in the output, so I create a. Call Transaction vs Session MethodIn session method we transfer data from internal table to database table though sessions.Call Transaction is a techniques similar to session method, while batch.
Now go to ABAP Editor (SE38). Enter the following code:.Structure for error message TYPES: BEGIN OF tyserror, msgerr( 60 ) TYPE c, END OF tyserror.Input Path SELECTION- SCREEN BEGIN OF BLOCK blck WITH FRAME TITLE text - 011. PARAMETERS: pfile TYPE rlgrap-filename, ' File Path efile TYPE rlgrap-filename OBLIGATORY, ' Error File Path pmode TYPE c OBLIGATORY DEFAULT 'N'.
' Mode SELECTION- SCREEN END OF BLOCK blck. Structure Decleration DATA: BEGIN OF fsfield, bsart TYPE eban-bsart, ' Document Type. Matnr TYPE eban-matnr, ' Material Number.
![]()
Menge TYPE eban-menge, ' Quantity Requested. Werks TYPE eban-werks, ' Plant. END OF fsfield.Internal table decleration DATA: tfield LIKE TABLE OF fsfield, tbdcdata LIKE TABLE OF bdcdata. DATA: fsbdcdata LIKE LINE OF tbdcdata, ' Structure type of bdcdata wstr TYPE string. Data decleration DATA: wapath TYPE string, waerror TYPE string, wacnt TYPE i, wmode TYPE c, wacnt1( 2 ) TYPE n, itoutput type table of tyserror, waoutput like line of itoutput. AT SELECTION- SCREEN. Mode 'A' = Foreground mode. Mode 'N' = Background mode IF pmode = 'A' OR pmode = 'N'.Error Message MESSAGE 'PLEASE ENTER THE MODE A or N' TYPE 'E'. Opening window for path selection AT SELECTION- SCREEN ON VALUE -REQUEST FOR pfile. CALL FUNCTION 'F4FILENAME' EXPORTING programname = syst-cprog dynpronumber = syst-dynnr fieldname = ' ' IMPORTING filename = pfile. TYPES: fsstruct( 4096 ) TYPE c OCCURS 0.
DATA: wstruct TYPE fsstruct. CALL FUNCTION 'TEXTCONVERTXLSTOSAP' EXPORTING ifieldseperator = 'X'. ILINEHEADER = itabrawdata = wstruct ifilename = pfile TABLES itabconverteddata = tfield EXCEPTIONS conversionfailed = 1 OTHERS = 2. IF sy-subrc 0. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.Opening window for Error file download AT SELECTION- SCREEN ON VALUE -REQUEST FOR efile. CALL FUNCTION 'F4FILENAME' EXPORTING programname = syst-cprog dynpronumber = syst-dynnr fieldname = ' ' IMPORTING filename = efile.
START- OF -SELECTION. LOOP AT tfield INTO fsfield. CLEAR fsbdcdata. PERFORM populatebdcdata. PERFORM insertdata.(populatebdcdata). part 1 FORM populatebdcdata.
PERFORM: fillbdcdata USING 'SAPMM06B' '0100' 'X' ' ' ' ', fillbdcdata USING ' ' ' 'EBAN-BSART' fsfield-bsart, ' Document Type. Fillbdcdata USING ' ' ' 'BDCOKCODE' '/00', ' Enter. Fillbdcdata USING 'SAPMM06B' '0106' 'X' ' ' ' ', fillbdcdata USING ' ' ' 'EBAN-MATNR(01)' fsfield-matnr, ' Material Number. Fillbdcdata USING ' ' ' 'EBAN-MENGE(01)' fsfield-menge, ' Quantity Requested. Fillbdcdata USING ' ' ' 'EBAN-WERKS(01)' fsfield-werks, ' Plant. Fillbdcdata USING ' ' ' 'BDCOKCODE' '/00', ' Enter.
Fillbdcdata USING 'SAPMM06B' '0102' 'X' ' ', fillbdcdata USING ' ' ' 'BDCOKCODE' '=BU'. part 2 FORM fillbdcdata USING value (pprogram) value (pdynpro) value (pdynbegin) value (pfnam) value (pfval). CLEAR fsbdcdata. IF pdynbegin = 'X'. Fsbdcdata- program = pprogram. Fsbdcdata- dynpro = pdynpro. APPEND fsbdcdata TO tbdcdata.
CONDENSE fsbdcdata-fval. APPEND fsbdcdata TO tbdcdata. ' Fillentry.(insertdata). FORM insertdata.Data decleration for Error Message DATA: tmsg TYPE TABLE OF bdcmsgcoll, ' Collecting Error messages wmsg TYPE bdcmsgcoll, wmsg1( 51 ). Call transaction 'ME51' CALL TRANSACTION 'ME51' USING tbdcdata MODE wmode UPDATE 'S' MESSAGES INTO tmsg. IF sy-subrc EQ 0. Uploaded into the database WRITE:/ 'DATA UPLOADED IN TABLE EBAN.'
. Error Found LOOP AT tmsg INTO wmsg WHERE msgtyp EQ 'E'. Format Message CALL FUNCTION 'MESSAGETEXTBUILD' EXPORTING msgid = wmsg-msgid msgnr = wmsg-msgnr msgv1 = wmsg-msgv1 msgv2 = wmsg-msgv2 msgv3 = wmsg-msgv3 msgv4 = wmsg-msgv4 IMPORTING messagetextoutput = wmsg1.Error message in downloaded file data: wastring( 10 ) type c. Concatenate wastring waoutput-msgerr into waoutput-msgerr separated by space. APPEND waoutput-msgerr TO itoutput. CALL FUNCTION 'GUIDOWNLOAD' EXPORTING.
BINFILESIZE = filename = waerror. FILETYPE = 'ASC'.
APPEND = ' ' writefieldseparator = 'X' TABLES datatab = itoutput. IF sy-subrc 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ' IF sy-subrc 0.
'insertdata Run the Program. Enter the path of file you need to upload. And then enter the path of a file where error log will be created. Finally select the mode.
We have following option for the mode. A = Foreground (Step by step processing will be done by you) 2. N = Background (All the Processing will be done in Background) 3. E = Display Error ( If there is any error, it will be displayed in log otherwise it is similar to background mode) Finally when all the data is uploaded.
In case of Error in the upload of any data, an Error file gets generated at the above given path. Please send us your feedback/suggestions at. © 2006-2007 SAPTechnical.COM. All rights reserved. All product names are trademarks of their respective companies. SAPTechnical.COM is in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver, and and any other SAP trademarks are registered trademarks of SAP AG in Germany and in several other countries.
Screen Loop Latch Youtube
Every effort is made to ensure content integrity. Use information on this site at your own risk. Graphic Design.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |