ABAP4 Beginner Examples I showed an instance to beginners, telling the Simple processes of ABAP development reports. The correctness of the program is not discussed with the discussion, we only care about the process of writing this program. First, in the beginning of any program, we must determine the table that will be used. The program we talk about is to query if the purchase order is completed. The following three tables are used: EKKO, EKPO, EKET. The beginning of the program is: Program Test.Tables: EKKO, EKET, EKPO. Now we have defined the table you want to use, the next job is to define internal tables and data. The internal table is used to store the data we queried from the above three tables. The relevant definitions are as follows: Data: Begin of Itab Occurs 0, Ebeln Like Ekko-Ebeln, Menge Like Ekpo-Menge, Wemng Like Eket-Wem, End Of Itab. Now we have defined the inner table ITAB. Then we will define the data. Data is like constants in C language. The relevant definition is as follows: Data: Matnr Like Ekpo-Matnr, Menge Like Ekpo-Matnr, Wemng Like Eket-Wem, Ebeln Like Ekpo-Ebeln. Here we have defined the data and internal tables to be used in the program. . The work we have to do is to choose the screen. The so-called selection screen is the content you want to enter from the screen when the program is run. For example, when a program is running, you can get a material number, you can get the current stock number of the material, then you have to write a screen for the query to enter the query. The relevant definition is as follows: SELECT-OPTIONS: EBELN1 For Ekko-Ebeln, Bedat for Ekko-Bedat, Ekgrp for Ekko-Ekgrp.Parameters: R1 Radiobutton Group Radi, R2 Radiobutton Group Radi, R3 Radiobutton Group Radi. Now we have completed programs. The previous preparation, then start the real to query the relevant data we need. Its code is as follows: SELECT K ~ Ebeln Into Corresponding Fields of Table Itab from Ekko As K Where k ~ Ebeln in Ebeln1 and K ~ Bedat in bedat and k ~ ekgrp in ekGRP.
Loop at itab. SELECT SUM (Menge) INTO ITAB-MENGE FROM EKPO WHERE EBELN EQ ITAB-Ebeln. Modify Itab.Endloop.
Loop at itab. Select SUM (WEMNG) INTO ITAB-WEMNG AUE EBELN EQ ITAB-EBELN. MODIFY ITAB.ENDLOOP. Then we need to define the output interface. There is an output format when the data we queried is, so that you will look convenient. The code is as follows: top-of-page. Write: / 'Purchasing Volume ID', 22 'Material Number', 47 'Purchase Order Quantity', 77 'Received Cargo Quantity', 95 'Completed Sign'. Uline AT / 1 ( 130). Nend-of-page .start-of-selection. The end is the output of the data we find. In fact, I am inserting some queries when I am going to this step, so it is relatively long. The code is as follows: if r1 = 'x'loop at itab. Select S ~ Matnr S ~ Matnr, Matnr, Matnr, Matnge, Wemng, EBELN) from eKPO AS SINNER JOIN EKET AS P on S ~ EBELP = P ~ Ebelp and s ~ ebeln = p ~ ebeln where s ~ ebeln = itab-ebeln. If itab-menge> Itab-Wemng. Write: / 2 Ebeln, 23 Matnr, 41 Menge, 71 WesNG, 97 'No'. Uline AT / 1 (130). Clear: Ebeln, Matnr, Menge, Wemng. Endif. Endselect.endloop.
Elseif R2 = 'X'.Loop At Itab. Select S ~ Matnr s ~ Menge P ~ Wemng s ~ Ebeln Into (Matnr, Matnge, Wemng, Ebeln) from ekpo as s inner Join Eket AS P on S ~ Ebelp = P ~ Ebelp and s ~ ebeln = p ~ ebeln where s ~ ebeln = itab-ebeln. If itab-menge <= itab-write: / 2 Ebeln, 23 Matnr, 41 Menge, 71 Wemng, 97 'is'. Uline At / 1 (130). Clear: Ebeln, Matnr, Menge, Wemng. Endif. Endselect.endloop.
Else.loop at itab.
SELECT S ~ MATNR S ~ Menge P ~ Wemng s ~ Ebeln Into (Matnr, Menge, Wemng, Ebeln) from ekpo as s inner Join Eket AS P on S ~ Ebelp = P ~ Ebelp and S ~ Ebeln = P ~ Ebeln WHERE S ~ Ebeln = itab-ebeln. If itab-menge> ITAB-WRITE: / 2 Ebeln, 23 Matnr, 41 Menge, 71 Wemng, 97 'No'. Uline AT / 1 (130). Clear: Ebeln, Matnr, Menge, Wemng. Endif. Endselect. Endloop.endif.loop at itab.if R3 = 'x' and itab-menge <= itab-wemng. SELECT S ~ MATNR S ~ MENGE P ~ WEMNG S ~ Ebeln Into (Matnr, Matnr, Menge , Wemng, Ebeln) from eKET AS P on S ~ EBELP = P ~ EBELN WHERE S ~ Ebeln = P ~ Ebeln WHERE S ~ EBELN = ITAB-EBELN. WRITE: / 2 EBELN, 23 MATNR, 41 MENGE 71 WEMNG, 97 'is'. Uline AT / 1 (130). Clear: Ebeln, Matnr, Menge, Wemng. Endselect. Endif.endloop. At this time, the program is over. In fact, this example is that you want everyone to know a regular process of ABAP development reports, not to tell what tips, hoping to be a bit used for beginners. Pouring bricks!