ABAP Programs

c

c
c
c
c
c
c 

c 


WRITE: / 'Multiplication of ENDIF. p_num2. result. PARAMETERS: c1 AS CHECKBOX. . IF divi = 'X'. p_num1. WRITE: / 'p_num1 = '. / 'p_num2 = '. p_num1. ENDIF. result. PARAMETERS: p_num1 TYPE i.  c c REPORT ztraining_prog1. WRITE: / 'Addition two numbers='. / 'p_num2 = '. IF NOT p_num2 IS INITIAL. result = p_num1 / p_num2. WRITE: / 'p_num1 = '. p_num2. divi RADIOBUTTON GROUP g1. result. two numbers='. mul RADIOBUTTON GROUP g1. DATA: result TYPE i. IF mul = 'X'. WRITE: / 'Division of ENDIF. p_num2 TYPE i. / 'p_num2 = '. p_num2. WRITE: / 'p_num1 = '. result = p_num1 * p_num2. ENDIF. two numbers='. result = p_num1 + p_num2. subt RADIOBUTTON GROUP g1. p_num1. IF add = 'X'. PARAMETERS: add RADIOBUTTON GROUP g1.

p_num1. Program 2:c c c c c c c c   . two numbers='. result.p_num2. WRITE: / 'p_num1 = '. p_num2. / 'p_num2 = '. WRITE: / 'Subtraction of ENDIF. result = p_num1 .IF subt = 'X'.

.

WRITE: / 'WHEN C block has executed since p_var1='. p_var1. write: / 'after endcase'. WHEN 'A'. WHEN 'B'. WRITE: / 'WHEN B block has executed since p_var1='. CASE p_var1. p_var1. PARAMETERS: p_var1 TYPE c. Program3: . p_var1.  c c REPORT ztraining_prog2. WHEN OTHERS. ENDCASE. WRITE: / 'WHEN others block has executed since p_var1 not equal to A or B or C p_var1 = '. WHEN 'C'. WRITE: / 'WHEN A block has executed since p_var1='. P_VAR1.

c c c c c c c c   .

.

WRITE: / SY-INDEX. 15 ENDDO. Program4: c c c c c c c c   . DO NUM1 TIMES. 'HP GLOBAL SOFT PVT.  c c REPORT ZTRAINING_PROG3.LTD' . PARAMETERS: NUM1 TYPE I.

.

EXIT. ENDIF. num1 = num1 + 1. ENDDO. DATA: num1 TYPE i. IF num1 GE 20.  c c REPORT ztraining_prog4. DO. WRITE: / 'NUM1 = '. num1. Program5: c c c   .

.

 c .

c  .c c c c c c REPORT ztraining_prog5.

APPEND itab. itab-deptcode = 'FICO'. itab-salary = '20000. . itab-salary = '29000.00' . itab-empname = 'NALINI'.00' .00' . itab-empno = 2. CLEAR itab. END OF itab. itab-salary = '18000. CLEAR itab. itab-empno = 4. itab-empname = 'RADHA kRISHNA'. APPEND itab. APPEND itab. APPEND itab. deptcode(4) TYPE c. c  itab-empno = 1. itab-empname = 'RAJESH'. itab-deptcode = 'HR'. itab-deptcode = 'IT'. CLEAR itab. itab-empno = 3. empname(40) TYPE c.00' . empno TYPE i. itab-deptcode = 'PURC'. itab-empname = 'ARUNA'. salary(12) TYPE p DECIMALS 2. itab-salary = '28000. DATA: BEGIN OF itab OCCURS 0.

CLEAR itab. c.

60 'DEPTCODE'. ENDLOOP. 15 itab-empname. c  ! . SKIP 5.NO'. ULINE. WRITE: / itab-empno. c LOOP AT itab.  WRITE: / 'EMP. 60 itab-deptcode. 75 itab-salary. WRITE: / 'After sort'. 15 'EMPNAME'. 75 'SALARY'.

75 itab-salary. LOOP AT itab. 60 itab-deptcode. 15 itab-empname. "#$%!$& SORT itab ASCENDING BY empname. c!'!$% c  " !(. WRITE: / itab-empno. ENDLOOP.

)*#$%!$+.  . c'-'+.

SKIP 4. WRITE: / 'After read'. WRITE: / itab-empno. . 75 itab-salary.& read table itab index 3. 15 itab-empname. else. ------------------------------------------------------------------------Program6: c c c   . IF sy-subrc = 0. write: / 'Read is failed'. 60 itab-deptcode. ENDIF.

.

. c c c c c .

c c REPORT ztraining_prog6. c  .

. itab-empno = 2.00' . itab-empname = 'RADHA kRISHNA'. itab-empname = 'ARUNA'. itab-deptcode = 'HR'.00' . salary(12) TYPE p DECIMALS 2. CLEAR itab. CLEAR itab. itab-deptcode = 'FICO'. empno TYPE i. DATA: BEGIN OF itab OCCURS 0. c  itab-empno = 1.00' . APPEND itab. itab-salary = '28000. itab-deptcode = 'IT'. CLEAR itab. itab-empname = 'NALINI'.00' . CLEAR itab. itab-salary = '18000. itab-deptcode = 'PURC'. empname(40) TYPE c. itab-salary = '29000. deptcode(4) TYPE c. APPEND itab. END OF itab. itab-empname = 'RAJESH'. itab-salary = '20000. APPEND itab. itab-empno = 3. itab-empno = 4. APPEND itab.

c.

itab-salary = 23000 . 15 itab-empname. modify itab transporting salary. ENDLOOP. 60 itab-deptcode. skip 4. 60 itab-deptcode. SKIP 5. delete itab. c!$' / c0! !& c c  !'-'+. 60 'DEPTCODE'. delete itab index 2. c LOOP AT itab. endloop. LOOP AT itab. ENDLOOP. 60 itab-deptcode. WRITE: / itab-empno.).NO'. ENDLOOP. WRITE: / itab-empno. endloop. 75 'SALARY'. write:/ 'After delete'. WRITE: / itab-empno. 15 'EMPNAME'.& c !!0!/+111& c$' / !!% %2!0!/& c%' & c c%'0& loop at itab where deptcode = 'HR' . 75 itab-salary. modify itab index sy-tabix transporting salary. . 15 itab-empname. write: / 'After Modify'. 75 itab-salary. 75 itab-salary.  WRITE: / 'EMP. itab-salary = 32000. 15 itab-empname. ULINE. loop at itab where deptcode = 'FICO'. LOOP AT itab.

------------------------------------------------------------------------Program7: c c c c c c c c   .

.

DATA: TOTNOOFREC TYPE I. c c REPORT ztraining_prog7. c  . .

itab-empname = 'ARUNA'. DATA: BEGIN OF itab OCCURS 0. CLEAR itab. CLEAR itab. itab-empname = 'RADHA kRISHNA'. END OF itab. itab-deptcode = 'PURC'. itab-salary = '20000. itab-empname = 'RAJESH'. itab-empno = 3. c  itab-empno = 1.00' . deptcode(4) TYPE c.00' . APPEND itab. . empname(40) TYPE c. APPEND itab. empno TYPE i.00' . itab-salary = '28000. salary(12) TYPE p DECIMALS 2. CLEAR itab. APPEND itab. itab-deptcode = 'HR'. itab-salary = '18000. itab-empno = 2. itab-deptcode = 'IT'.

CLEAR itab. APPEND itab.00' . APPEND itab. itab-empname = 'SRIKANTH'. itab-empname = 'MEENA'. itab-salary = '29000. itab-deptcode = 'HR'. itab-deptcode = 'FICO'. c. itab-salary = '22000. itab-empno = 6. APPEND itab. itab-empname = 'NALINI'. CLEAR itab. itab-salary = '19000.00' . CLEAR itab. itab-deptcode = 'PURC'.itab-empno = 4. itab-empno = 5.00' .

75 itab-salary. 75 itab-salary. 15 'EMPNAME'. ENDLOOP. 60 'DEPTCODE'.  WRITE: / 'EMP. 60 itab-deptcode. WRITE: / itab-empno. LOOP AT itab. DELETE ADJACENT DUPLICATES FROM itab COMPARING deptcode. 60 itab-deptcode. 15 itab-empname. ENDLOOP. . WRITE: / itab-empno. 75 'SALARY'. SKIP 5. DESCRIBE TABLE ITAB LINES TOTNOOFREC. WRITE: / 'AFTER DELETE'. 15 itab-empname. c LOOP AT itab.NO'. SORT itab ASCENDING BY DEPTCODE. ULINE.

------------------------------------------------------------------------Program8: c c c c c c c c   .OF RECORDS IN ITAB='. TOTNOOFREC.WRITE: / 'TOTAL NO.

.

COLLECT itab. COLLECT itab. itab-f2 = 'C'. itab-f3 = 30. CLEAR itab. itab-f3 = 25. COLLECT itab. f1 TYPE c. CLEAR itab. itab-f1 = 'A'. itab-f1 = 'A'. f3 TYPE i. . itab-f2 = 'B'. itab-f1 = 'A'. END OF itab. itab-f3 = 10. 3 c c REPORT ztraining_prog8. itab-f2 = 'B'. f2 TYPE c. itab-f1 = 'B'. itab-f2 = 'C'. CLEAR itab. DATA: BEGIN OF itab OCCURS 0.

COLLECT itab. CLEAR itab. ------------------------------------------------------------------------Program9: c c c c c c c c   . 5 itab-f2. LOOP AT itab. COLLECT itab. CLEAR itab. WRITE: / itab-f1. itab-f1 = 'A'. itab-f2 = 'C'.itab-f3 = 20. itab-f3 = 20. 10 itab-f3. ENDLOOP.

.

4 c c REPORT ZTRAINING_PROG9. matnr TYPE vbap-matnr. SELECT matnr vbeln posnr . vbeln TYPE vbap-vbeln. DATA: g_subtotal TYPE vbap-kwmeng. posnr TYPE vbap-posnr. SELECT-OPTIONS: s_matnr FOR itab-matnr. DATA: BEGIN OF itab OCCURS 0. g_grandtotal TYPE vbap-kwmeng. kwmeng TYPE vbap-kwmeng. END OF itab.

g_subtotal = g_subtotal + itab-kwmeng.kwmeng FROM vbap INTO TABLE itab WHERE matnr IN s_matnr. 55 'item.No'. 55 g_subtotal.no'. 45 'item. ENDAT. 45 itab-posnr. 55 g_grandtotal. AT LAST. SORT itab. AT NEW matnr. AT FIRST. WRITE: / 'Material. FORMAT COLOR 7. IF sy-subrc = 0. AT END OF matnr. WRITE: /45 'GRANDTOTAL=' . CLEAR g_subtotal. WRITE: /45 'SUBTOTAL=' . FORMAT RESET. g_grandtotal = g_grandtotal + itab-kwmeng. FORMAT RESET. LOOP AT itab.no'. ENDAT. . ENDAT. ENDIF. FORMAT COLOR 6. ENDLOOP. WRITE:/25 itab-vbeln. WRITE: / itab-matnr. 55 itab-kwmeng. ENDAT. 25 'Salesord.qty'.

------------------------------------------------------------------------Program10: c c c c c c c c   .

.

 c c REPORT ztraining_prog10. c  .

salary(12) TYPE p DECIMALS 2. deptcode(4) TYPE c. empname(40) TYPE c. 516 empno TYPE i. types: BEGIN OF ty_itab. c 7". END OF ty_itab.

 #-6 c!0!/:. 89! !6516 c$% # 6 c$%!$:1. #. #-6 c'-':.

wa_itab-empname = 'ARUNA'. wa_itab-empname = 'RADHA kRISHNA'. . c  wa_itab-empno = 1. wa_itab-empno = 3. wa_itab-salary = '18000. DATA: itab type TABLE OF ty_itab. wa_itab-empname = 'RAJESH'. APPEND wa_itab TO itab. CLEAR wa_itab. wa_itab-deptcode = 'IT'. APPEND wa_itab TO itab. wa_itab-empno = 2.< 6 c 89! !& data: wa_itab type ty_itab.00' . wa_itab-salary = '28000.00' . CLEAR wa_itab. wa_itab-deptcode = 'HR'.

00' . APPEND wa_itab TO CLEAR wa_itab. CLEAR wa_itab. wa_itab-salary = '20000. wa_itab-empno = 4.00' . itab. wa_itab-salary = '29000. wa_itab-deptcode = 'FICO'. c.wa_itab-deptcode = 'PURC'. wa_itab-empname = 'NALINI'. APPEND wa_itab TO itab.

NO'. WRITE: / 'After sort'. 60 wa_itabdeptcode.  WRITE: / 'EMP. 75 wa_itab-salary. ULINE. SKIP 5. 75 'SALARY'. WRITE: / wa_itab-empno. 15 wa_itab-empname. 60 'DEPTCODE'. c  ! . c LOOP AT itab INTO wa_itab. ENDLOOP. 15 'EMPNAME'.

WRITE: / wa_itab-empno. c!'!$% c  " !(. LOOP AT itab INTO wa_itab. "#$%!$& SORT itab ASCENDING BY empname. 15 wa_itab-empname. 75 wa_itab-salary. ENDLOOP. 60 wa_itabdeptcode.

 . )*#$%!$+. c'-'+.

IF sy-subrc = 0.& READ TABLE itab INTO wa_itab INDEX 3. SKIP 4. WRITE: / 'After read'. . 15 wa_itab-empname. WRITE: / wa_itab-empno. 60 wa_itab- .

deptcode. ENDIF. ENDLOOP. LOOP AT itab INTO wa_itab WHERE deptcode = 'HR'. MODIFY itab FROM wa_itab TRANSPORTING salary. ------------------------------------------------------------------------Program11: c c c c c c c c   . 75 wa_itab-salary. wa_itab-salary = 24000. WRITE: / 'Read is failed'. delete itab from wa_itab. ELSE.

.

date type d. include structure vbap. data: begin of itab3. data: end of itab3. data: itab2 like vbap occurs 0 with header line. wa_itab type vbap.  c c REPORT ZTRAINING_PROG11. data: itab type table of vbap. ------------------------------------------------------------------------Program12: c c c   . data: name(40) type c.

.

 .

name. include ZTEST_INCLUDE1. result = var1 * var2. 'Result='. var2. var2 = 5. ------------------------------------------------------------------------Program13: c c c c c c c c   . write: / / / / 'var1='. 'name =' . result. result type i.c c c c c c c REPORT ZTRAINING_PROG12. 'var2='. var1. data: var2 type i.

.

num1 = 40.  c c REPORT ZTRAINING_PROG13. perform calculations using num1. . data: num1 type i. write: / 'Before calling subroutine num1='. num1.

c c c 8$  .write: / 'After calling subroutine num1='. num1.

  c c c= cc c> <= cc form CALCULATIONS using p_num1. 5  . p_num1 = p_num1 . endform.10.

    2!$7 c c c c c c c c   .

.

perform calculations using num1.  c c REPORT ZTRAINING_PROG14. write: / 'Before calling subroutine num1='. num1 = 40. write: / 'After calling subroutine num1='. num1. c c c 8$  . num1. data: num1 type i.

  c c .

5  . p_num1 = p_num1 .10. endform.c= cc c> <= cc form CALCULATIONS using value(p_num1).

    2!$7 c c c c c c c c   .

.

write: / 'Before calling subroutine num1='. data: num1 type i. perform calculte changing num1. write: / 'After calling subroutine num1='. num1. num1. c c c 8$   c c c= cc c? <= cc form CALCULTE changing value(p_num1). .  c c REPORT ZTRAINING_PROG15. num1 = 40.

5     2!$.p_num1 = p_num1 .7 c c c c c c c c   .10. endform.

.

PERFORM populate_intab TABLES itab. DATA: BEGIN OF itab OCCURS 0. c c REPORT ztraining_prog16. c$@ %2!$  . PERFORM display_output. END OF itab. num1 TYPE i. .

.

& c c c 8$ .

" c c c= cc c>.

APPEND itab. CLEAR itab. "= cc FORM populate_intab TABLES p_itab LIKE itab[]. itab-num1 = sy-index. DO 5 TIMES. ENDFORM. 5 . ENDDO.

" c c .

c 8$.

LOOP AT itab. #  c c c= cc c>= c?= cc FORM display_output . ENDLOOP. ENDFORM. 5. WRITE: / itab-num1.

 #     2!$A7 c c c c c c c c   .

.

A c c REPORT ztraining_prog17. DATA: g_result TYPE i. num3 TYPE i. . g_result. num2 TYPE i. SUBMIT ZTRAINING_PROG16 AND RETURN. write: / 'g_result = '. CALL FUNCTION 'ZCALCULATIONS' EXPORTING var1 = num1 var2 = num2 var3 = num3 var4 = num4 IMPORTING RESULT = g_result. num4 TYPE I. PARAMETERS: num1 TYPE i.

------------------------------------------------------------------------Program18: c c c c c c c c   .

.

IF sy-subrc <> 0. CALL FUNCTION 'ZGET_MATERIALS' EXPORTING v_mtart = p_mtart TABLES it_mara = itab EXCEPTIONS no_data_found = 1 OTHERS = 2. 3 c c REPORT ztraining_prog18. PARAMETERS: p_mtart TYPE mara-mtart. c< . DATA: itab LIKE mara OCCURS 0 WITH HEADER LINE.

#<.

 ##< # <"#<  c(.

LOOP AT itab. ENDIF. )#<B#<B#<B#<B& WRITE: / 'nO MATERIAL AVAILABLE FOR GIVEN MATERIAL TYPE='. IF sy-subrc = 0. ENDLOOP. WRITE: / itab-matnr. ------------------------------------------------------------------------- . ENDIF. p_mtart.

.

Sign up to vote on this title
UsefulNot useful