Core Abap Notes With Programs

download Core Abap Notes With Programs

of 294

Transcript of Core Abap Notes With Programs

  • 7/30/2019 Core Abap Notes With Programs

    1/294

    1 | P a g e S a n t o s h P

    INDEX..

    1.WELCOME PROGRAM 1

    Z9AMPROGRAM1:REPORT Z9AMPROGRAM1.

    write'welcome'.

    Z9AMPROGRAM2:

    REPORT Z9AMPROGRAM2.

    dataxtypei. "declaration

    data y typei.

    dataztypei.

    x = 10. "initialization

    y = 20.z = x + y.

    write : ' a + b = ',z. "display

    Z9AMPROGRAM3:

    REPORT Z9AMPROGRAM3.

    data : xtypei,

    y typei,

  • 7/30/2019 Core Abap Notes With Programs

    2/294

    2 | P a g e S a n t o s h P

    ztypei.

    x = 10.

    y = 20.

    z = x + y.

    writez.

    write : / 'sum of two numbers is ',z.

    write :/ 'sum of two numbers is ',zleft-justified.

    write :/ 'sum of two numbers is ',zcentered.

    Z9AMPROGRAM4:

    REPORT Z9AMPROGRAM4.

    *parameters x type i.

    *parameters y type i.

    parameters : abc typeidefault20 ,

    y typeidefault10 obligatory .

    dataztypei.

    z = abc + y.

    writez.

    Z9AMPROGRAM5:

    REPORT Z9AMPROGRAM5.

    data : xtypeivalue10,

    y typeivalue20,

    ztypei.

    z = x + y.

  • 7/30/2019 Core Abap Notes With Programs

    3/294

    3 | P a g e S a n t o s h P

    writez.

    x = 34.

    y = 44.

    z = x + y.

    write / z.

    constantsmtypeivalue56.

    write :/ m.

    *m = 57.

    Z9AMPROGRAM6:

    REPORT Z9AMPROGRAM6.

    dataxtypei.

    writex.

    data y typec.

    write :/ 'y is ',y.

    y = 'Gensoft'.

    write :/ y.

    datam(10) typec.m = 'Gensoft systems'.

    write / m.

    data k type string.

    k = 'Gensoft systems'.

    write / k.

    Z9AMPROG

    RAM7:

  • 7/30/2019 Core Abap Notes With Programs

    4/294

    4 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM7.

    parameters : xtypei,

    y typei.

    data r typei.

    parameters : r1 radiobuttongroup g1,

    r2 radiobuttongroup g1 ,

    r3 radiobuttongroup g1 default'X',

    r4 radiobuttongroup g1.

    if r1 = 'X'.

    r = x + y.

    write :/ 'sum is ',r.

    elseif r2 = 'X'.

    r = x - y.

    if r >= 0.

    write :/ 'Difference is ',r.else.

    write :/ 'Difference is -'no-gap,r no-signleft-justified.

    endif.

    elseif r3 = 'X'.

    r = x * y.

    write :/ 'Product is ',r.

    elseif r4 = 'X'.

    r = x / y.

    write :/ 'Division is ',r.

    endif.

    FIRST SCREEN :ENTER INPUTS AND SELECT RADIO BUTTON AND PRESS EXECUTE

    SECOND SECEND SCREEN :

  • 7/30/2019 Core Abap Notes With Programs

    5/294

    5 | P a g e S a n t o s h P

    Z9AMPROGRAM8:

    REPORT Z9AMPROGRAM8.

    parameters : xtypei,

    y typei.

    data r typei.

    parameters : r1 ascheckbox,r2 ascheckbox,

    r3 ascheckbox,

    r4 ascheckbox.

    if r1 = 'X'.

    r = x + y.

    write :/ 'sum is ',r.

    endif.

    if r2 = 'X'.

    r = x - y.

    if r >= 0.

    write :/ 'Difference is ',r.else.

    write :/ 'Difference is -'no-gap,r no-signleft-justified.

    endif.

    endif.

    if r3 = 'X'.

    r = x * y.

    write :/ 'Product is ',r.

    endif.

    if r4 = 'X'.

    r = x / y.

    write :/ 'Division is ',r.

    endif.

    FIRST SCREEN: ENTER THE VALUES AND AND TICK THE CHECK BOXES AND PRESS EXECUTE

  • 7/30/2019 Core Abap Notes With Programs

    6/294

    6 | P a g e S a n t o s h P

    ECEND SCREEN: OUTPUT

    Z9AMPROGRAM9:

    REPORT Z9AMPROGRAM9.

    parametersxtypeidefault7.

    data : y typeivalue1,

    ztypei.

    while y le10.

    if y ne4.

    z = x * y.

    write :/ x,'*',y,'=',z.

    endif.

    y = y + 1.endwhile.

    FIRST SCREEN:

  • 7/30/2019 Core Abap Notes With Programs

    7/294

    7 | P a g e S a n t o s h P

    SECEND SCREEN: OUTPUT

    Z9AMPROGRAM10:

    REPORT Z9AMPROGRAM10.

    parametersxtypeidefault7.

    data : y typeivalue1,

    ztypei.

    while y le10.

    if y eq4.

    y = y + 1.

    continue.

    endif.

    z = x * y.

    write :/ x,'*',y,'=',z.y = y + 1.

    endwhile.

    FIRST SCREEN:

  • 7/30/2019 Core Abap Notes With Programs

    8/294

    8 | P a g e S a n t o s h P

    SECEND SCREEN:

    Z9AMPROGRAM11:

    REPORT Z9AMPROGRAM11.

    parametersxtypeidefault7.

    data : y typeivalue1,

    ztypei.

    while y le10.

    if y eq4.

    exit.

    endif.

    z = x * y.

    write :/ x,'*',y,'=',z.y = y + 1.

    endwhile.

    write :/ 'end of program'.

    FIRST SCREEN:

  • 7/30/2019 Core Abap Notes With Programs

    9/294

    9 | P a g e S a n t o s h P

    SECEND SCREEN:

    Z9AMPROGRAM12:

    REPORT Z9AMPROGRAM12 nostandardpage heading.

    write :/ 'hello'.

    exit.

    write :/ 'welcome'.

    write :/ 'bye'.

    Z9AMPROGRAM13:

    REPORT Z9AMPROGRAM13.

    data : xtypeivalue10,

    y typei.

    write :/ 'x is ',x,

    / 'y is ',y.

  • 7/30/2019 Core Abap Notes With Programs

    10/294

    10 | P a g e S a n t o s h P

    y = x.

    write :/ 'x is ',x,

    / 'y is ',y.

    x = 20.

    write :/ 'x is ',x,

    / 'y is ',y.

    Z9AMPROGRAM14:

    REPORT Z9AMPROGRAM14.

    DATA : xtypeivalue10.

    field-symbols .

    = x.

    PROGRAM WILL BE TERMINATED:THERE IS NO ASIGN KEY WORD SO I LEADS TO RUN TIME ERROR.

    Z9AMPROGRAM15:

    REPORT Z9AMPROGRAM15.

  • 7/30/2019 Core Abap Notes With Programs

    11/294

    11 | P a g e S a n t o s h P

    data : xtypeivalue10.

    field-symbols .

    assignxto .

    write :/ 'x is ',x,

    / ' is ',.

    x = 20.

    write :/ 'x is ',x,

    / ' is ',.

    = 30.

    write :/ 'x is ',x,

    / ' is ',.

    data y type string value'Gensoft'.assign y to .

    write :/ '**************'.

    write :/ 'x is ',x,

    / ' is ',,

    / 'y is ',y.

    Z9AMPROGRAM16:

    REPORT Z9AMPROGRAM16.

    data xtype d value'13042011'. "DDMMYYYY

  • 7/30/2019 Core Abap Notes With Programs

    12/294

    12 | P a g e S a n t o s h P

    write :/ x.

    x = '20110413'. "YYYYMMDD

    write :/ x. "ddmmyyyy

    write :/(10) x. "dd.mm.yyyy

    write :/(10) xusingeditmask'__/__/____'.

    data y type t value'102045'. "HHMMSS

    write :/ y. "HHMMSS

    write :/(8) y. "HH:MM:SS

    write :/(8) y usingeditmask'__-__-__'.

    write :/ 'Date is ',sy-datum,

    / 'Time is ',sy-uzeit.

    Z9AMPROGRAM17:

    REPORT Z9AMPROGRAM17.

    parameters : xtypei.

    write :/ 'hello'.

    ifx

  • 7/30/2019 Core Abap Notes With Programs

    13/294

    13 | P a g e S a n t o s h P

    OUTPUT 2:

    Z9AMPROGRAM18:

    REPORT Z9AMPROGRAM18.

    parameters : xtypei.

    write :/ 'hello'.

    checkx

  • 7/30/2019 Core Abap Notes With Programs

    14/294

    14 | P a g e S a n t o s h P

    write :/ 'welcome'.

    write :/ 'bye'.

    Z9AMPROGRAM19:

    REPORT Z9AMPROGRAM19.

    write :/ 'inside program 19'.

    *submit z9amprogram20.

    submit z9amprogram20 andreturn.

    write :/ 'end of program 19'.

    Z9AMPROGRAM20:

    REPORT Z9AMPROGRAM20.

    write :/ 'inside program20'.

  • 7/30/2019 Core Abap Notes With Programs

    15/294

    15 | P a g e S a n t o s h P

    Z9AMPROGRAM21:

    REPORT Z9AMPROGRAM21.

    parameters : p_x typei,

    p_y typei.

    export p_x tomemoryid'ABC'.

    export p_y tomemoryid'PQR'.submit z9amprogram22.

    Z9AMPROGRAM22:

    REPORT Z9AMPROGRAM22.

    data : k typei,

    p_x typei,

    p_y typei.

    import p_x frommemoryid'ABC'(001).

  • 7/30/2019 Core Abap Notes With Programs

    16/294

    16 | P a g e S a n t o s h P

    import p_y frommemoryid'PQR'.

    k = p_x + p_y.

    write :/ 'sum is ',k.

    Z9AMPROGRAM23:

    REPORT Z9AMPROGRAM23.

    parameters : str type string.

    data k typei.

    k = strlen( str ).

    write :/ 'length of string is ',k.

    Z9AMPROGRAM24:REPORT Z9AMPROGRAM24.

    data : str1 type string value'Gensoft',

    str2 type string value'Systems',

    str type string.

  • 7/30/2019 Core Abap Notes With Programs

    17/294

    17 | P a g e S a n t o s h P

    write :/ 'str is ',str.

    concatenate str1 str2 into str.

    write :/ 'str is ',str.

    str = ' '.

    write :/ 'str is ',str.

    concatenate str1 str2 into str separatedby' '.

    write :/ 'str is ',str.

    Z9AMPROGRAM25:

    REPORT Z9AMPROGRAM25.

    data : str type string

    value'Genesis,Software,Systems',

    str1 type string,

    str2 type string,

    str3 type string.

    write :/ 'str1 is ',str1,

    / 'str2 is ',str2,

    / 'str3 is ',str3.

    write :/ '********************'.

    split str at','into str1 str2.

    write :/ 'str1 is ',str1,

    / 'str2 is ',str2,

    / 'str3 is ',str3.

    write :/ '********************'.

    clear : str1,str2,str3.write :/ 'str1 is ',str1,

    / 'str2 is ',str2,

    / 'str3 is ',str3.

    write :/ '********************'.

    split str at','into str1 str2 str3.

    write :/ 'str1 is ',str1,

  • 7/30/2019 Core Abap Notes With Programs

    18/294

    18 | P a g e S a n t o s h P

    / 'str2 is ',str2,

    / 'str3 is ',str3.

    Z9AMPROGRAM26:

    REPORT Z9AMPROGRAM26.

    data : str type string value'GenSoft'.

    write :/ str.translate str tolowercase.

    write :/ str.

    translate str touppercase.

    write :/ str.

    Z9AMPROGRAM27:

  • 7/30/2019 Core Abap Notes With Programs

    19/294

    19 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM27.

    data : str1 type string

    value'Wipro Technologies',

    str2 type string

    value'Genesis software Systems'.

    write :/ 'str1 is ',str1,

    / 'str2 is ',str2.

    write :/ '*****************'.

    overlay str2 with str1.

    write :/ 'str1 is ',str1,

    / 'str2 is ',str2.

    Z9AMPROGRAM28:

    REPORT Z9AMPROGRAM28.

    data : str1 type string

    value'Gensoft Systems'.

    write :/ 'str1 is ',str1.

    write :/ '***************'.

    replace's'in str1 with'k'.

    write :/ 'str1 is ',str1.

    write :/ '***************'.

    str1 = 'Gensoft Systems'.write :/ str1.

    write :/ '***************'.

    replacealloccurrencesof's'in str1 with'k'.

    write :/ str1.

  • 7/30/2019 Core Abap Notes With Programs

    20/294

    20 | P a g e S a n t o s h P

    write :/ '***************'.

    str1 = 'Gensoft Systems'.

    write :/ str1.

    write :/ '***************'.

    replacealloccurrencesof's'in str1 with'k'

    ignoring case.

    write :/ str1.

    Z9AMPROGRAM29:

    REPORT Z9AMPROGRAM29.

    data : str1 type string value'Genesis',

    str2 type string.

    write :/ 'str1 is ',str1,

    / 'str2 is ',str2.

    transfer str1 to str2.

    write :/ 'str1 is ',str1,

    / 'str2 is ',str2.

    RUN TIME ERROR:

  • 7/30/2019 Core Abap Notes With Programs

    21/294

    21 | P a g e S a n t o s h P

    Z9AMPROGRAM30:

    REPORT Z9AMPROGRAM30.

    data : str type string value'Gensoft Systems'.

    write :/ 'str is ',str.

    condense str no-gaps.

    write :/ 'str is ',str.

    Z9AMPROGRAM31:

    REPORT Z9AMPROGRAM31.

    data : str1 type string value'Gensoft Systems',

    str2 type string.

  • 7/30/2019 Core Abap Notes With Programs

    22/294

    22 | P a g e S a n t o s h P

    write :/ 'str2 is ',str2.

    write :/ '******************'.

    str2 = str1+2(7).

    write :/ 'str2 is ',str2.

    Z9AMPROGRAM32:

    REPORT Z9AMPROGRAM32.

    data : cust(2) typecvalue'01'.

    write :/ 'cust is ',cust.

    data : cust1(3) typec.

    concatenate'c' cust+1(1) into cust1.

    write :/ 'cust1 is ',cust1.

    Z9AMPROGRAM33:

    REPORT Z9AMPROGRAM33.

    parameters : str type string lowercase.

    write :/ str.

  • 7/30/2019 Core Abap Notes With Programs

    23/294

    23 | P a g e S a n t o s h P

    Z9AMPROGRAM34:

    REPORT Z9AMPROGRAM34.

    data : beginof emp,

    empno typei,

    ename(20) typec,

    endof emp.

    write :/ emp-empno,

    emp-ename.

    emp-empno = 1.

    emp-ename = 'abc'.

    write :/ '************'.

    write :/ emp-empno,

    emp-ename.

    data : emp1 like emp.

    write :/ 'EMP1 structure....'.

    write :/ emp1-empno,

    emp1-ename.

    emp1 = emp.

    write :/ 'EMP1 structure after assignment....'.

    write :/ emp1-empno,

    emp1-ename.

    clear emp1.

    write :/ 'EMP1 structure after clear....'.

  • 7/30/2019 Core Abap Notes With Programs

    24/294

    24 | P a g e S a n t o s h P

    write :/ emp1-empno,

    emp1-ename.

    move emp to emp1.

    write :/ 'EMP1 structure after move....'.

    write :/ emp1-empno,

    emp1-ename.

    Z9AMPROGRAM35:

    REPORT Z9AMPROGRAM35.

    data : beginof emp,

    empno typei,

    ename(20) typec,

    endof emp.

    emp-empno = 1.

    emp-ename = 'abc'.

    write :/ 'EMP structure'.

    write :/ emp-empno,

    emp-ename.

    data : beginof dept,deptno typei,

    dname(30) typec,

    loc(30) typec,

    endof dept.

    move emp to dept.

  • 7/30/2019 Core Abap Notes With Programs

    25/294

    25 | P a g e S a n t o s h P

    write :/ 'DEPT structure....'.

    write :/ dept-deptno,

    dept-dname,

    dept-loc.

    Z9AMPROGRAM36:

    REPORT Z9AMPROGRAM36.

    data : beginof emp,

    ename(20) typec,

    empno typei,

    endof emp.

    emp-empno = 1.

    emp-ename = 'abc'.

    write :/ 'EMP structure'.

    write :/ emp-empno,emp-ename.

    *

    data : beginof dept,

    deptno typei,

    dname(30) typec,

    loc(30) typec,

    endof dept.

    move emp to dept.

    write :/ 'DEPT structure....'.

    write :/ dept-deptno,

    dept-dname,dept-loc.

  • 7/30/2019 Core Abap Notes With Programs

    26/294

    26 | P a g e S a n t o s h P

    Z9AMPROGRAM37:

    REPORT Z9AMPROGRAM37.

    data : beginof emp,

    empno typei,

    ename(20) typec,

    endof emp.

    emp-empno = 1.

    emp-ename = 'raju'.

    write :/ 'EMP structure'.

    write :/ emp-empno,

    emp-ename.

    data : beginof emp1,

    ename(20) typec,

    desig(20) typec,

    empno typei,

    endof emp1.

    move-corresponding emp to emp1.

    write :/ 'EMP1 structure'.

    write :/ 'Ename is ',emp1-ename,

    / 'Desig is ',emp1-desig,

    / 'empno is ',emp1-empno.

  • 7/30/2019 Core Abap Notes With Programs

    27/294

    27 | P a g e S a n t o s h P

    Z9AMPROGRAM38:

    REPORT Z9AMPROGRAM38.

    data : beginof emp,

    empno(3) typec,

    ename(20) typec,

    endof emp.

    emp-empno = 'a11'.

    emp-ename = 'raju'.

    write :/ 'EMP structure'.

    write :/ emp-empno,

    emp-ename.

    data : beginof emp1,

    ename(20) typec,

    desig(20) typec,

    empno typei,

    endof emp1.

    move-corresponding emp to emp1.

    write :/ 'EMP1 structure'.

    write :/ 'Ename is ',emp1-ename,

    / 'Desig is ',emp1-desig,

    / 'empno is ',emp1-empno.

  • 7/30/2019 Core Abap Notes With Programs

    28/294

    28 | P a g e S a n t o s h P

    Z9AMPROGRAM39:

    REPORT Z9AMPROGRAM39.

    data : beginof emp,

    empno typei,

    ename(20) typec,

    beginof dept,

    deptno typei,

    dname(20) typec,

    endof dept,

    desig(30) typec,

    endof emp.

    emp-empno = 1.

    emp-ename = 'raju'.

    emp-dept-deptno = 10.

    emp-dept-dname = 'Sales'.

    emp-desig = 'Manager'.

    write : emp-empno,

    emp-ename,

    emp-dept-deptno,

    emp-dept-dname,

    emp-desig.

  • 7/30/2019 Core Abap Notes With Programs

    29/294

    29 | P a g e S a n t o s h P

    Z9AMPROGRAM40:

    REPORT Z9AMPROGRAM40.

    data : beginof dept,

    deptno typei,

    dname(20) typec,

    endof dept.

    data : beginof emp,

    empno typei,

    ename(20) typec.

    includestructure dept.

    data : desig(30) typec,

    endof emp.

    emp-empno = 1.

    emp-ename = 'raju'.

    emp-deptno = 10.

    emp-dname = 'sales'.

    emp-desig = 'director'.

    write : / emp-empno,

    emp-ename,

    emp-deptno,

    emp-dname,

    emp-desig.

    Z9AMPROGRAM41:

  • 7/30/2019 Core Abap Notes With Programs

    30/294

    30 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM41.

    data : beginof emp occurs0,

    empno typei,

    ename(20) typec,

    endof emp.

    write :/ 'Header area'.

    write :/ emp-empno,

    emp-ename.

    emp-empno = 3.

    emp-ename = 'raju'.

    write :/ 'Header area'.

    write :/ emp-empno,

    emp-ename.

    append emp.

    emp-empno = 5.

    emp-ename = 'ravi'.

    append emp.

    emp-empno = 2.

    emp-ename = 'vamshi'.

    append emp.

    write :/ 'Body area'.loopat emp.

    write :/ emp-empno,

    emp-ename.

    endloop.

  • 7/30/2019 Core Abap Notes With Programs

    31/294

    31 | P a g e S a n t o s h P

    Z9AMPROGRAM42:

    REPORT Z9AMPROGRAM42.

    data : beginof emp occurs0,

    f1 typei,

    f2(20) typec,

    f3(30) typec,

    f4 type d,

    f5 type t,

    endof emp.

    select empno ename empdesig empjdate empjtime

    from ZGENESISEMP

    intotable emp.if sy-subrc eq0.

    loopat emp.

    write : / emp-f1,

    emp-f2,

    emp-f3,

    emp-f4,

    emp-f5.

    endloop.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    32/294

    32 | P a g e S a n t o s h P

    Z9AMPROGRAM43:

    REPORT Z9AMPROGRAM43.

    data : beginof emp occurs0,

    f1 type ZEMPNODE,

    f2 type zgenesisemp-ename,

    f3 type zgenesisemp-empdesig,

    f4 type datum,

    f5 type uzeit,

    endof emp.

    select empno ename empdesig empjdate empjtime

    from ZGENESISEMP

    intotable emp.

    if sy-subrc eq0.

    loopat emp.

    write :/ emp-f1,

    emp-f2,

    emp-f3,

    emp-f4,emp-f5.

    endloop.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    33/294

    33 | P a g e S a n t o s h P

    Z9AMPROGRAM44:

    REPORT Z9AMPROGRAM44.

    data : beginof emp occurs0,

    empno type ZEMPNODE,

    ename type zgenesisemp-ename,

    empdesig type zgenesisemp-empdesig,empjdate type datum,

    empjtime type uzeit,

    endof emp.

    select empno ename empdesig empjdate empjtime

    from ZGENESISEMP

    intotable emp.

    if sy-subrc eq0.

    loopat emp.

    write :/ emp-empno,

    emp-ename,

    emp-empdesig,emp-empjdate,

    emp-empjtime.

    endloop.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    34/294

    34 | P a g e S a n t o s h P

    Z9AMPROGRAM45:

    REPORT Z9AMPROGRAM45.

    data : beginof emp occurs0,

    mandt type mandt,

    empno type ZEMPNODE,

    ename type zgenesisemp-ename,

    empdesig type zgenesisemp-empdesig,

    empjdate type datum,

    empjtime type uzeit,

    endof emp.

    select *

    from ZGENESISEMP

    intotable emp.

    if sy-subrc eq0.

    loopat emp.

    write :/ emp-mandt,

    emp-empno,

    emp-ename,

    emp-empdesig,

    emp-empjdate,

    emp-empjtime.

    endloop.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    35/294

    35 | P a g e S a n t o s h P

    Z9AMPROGRAM46:

    REPORT Z9AMPROGRAM46.

    data : beginof emp occurs0.

    includestructure zgenesisemp.

    data endof emp.

    select *

    from ZGENESISEMP

    intotable emp.if sy-subrc eq0.

    loopat emp.

    write :/ emp-mandt,

    emp-empno,

    emp-ename,

    emp-empdesig,

    emp-empjdate,

    emp-empjtime.

    endloop.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    36/294

    36 | P a g e S a n t o s h P

    Z9AMPROGRAM47:

    REPORT Z9AMPROGRAM47.

    data : beginof emp occurs0.

    includestructure zgenesisemp.

    data endof emp.

    select empno ename

    from ZGENESISEMP

    into CORRESPONDING FIELDSOFTABLE emp.

    if sy-subrc eq0.

    loopat emp.

    write :/ emp-empno,

    emp-ename.

    endloop.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    37/294

    37 | P a g e S a n t o s h P

    Z9AMPROGRAM48:

    REPORT Z9AMPROGRAM48.

    *parameters : p_x(3) type c.

    *parameters : p_x type kna1-land1.

    parameters : p_land1 type kna1-land1.

    data : lt_kna1 like kna1 occurs0withheaderline.

    select kunnr land1 name1

    from kna1

    into corresponding fieldsoftable lt_kna1

    where land1 = p_land1.

    if sy-subrc eq0.

    write :/ 'No of records before describe:',sy-tfill.

    describetable lt_kna1.

    write :/ 'No of records after describe:',sy-tfill.

    else.

    write :/ 'No data'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    38/294

    38 | P a g e S a n t o s h P

    Z9AMPROGRAM49:

    REPORT Z9AMPROGRAM49.

    parameters : p_land1 type kna1-land1.

    data : lt_kna1 like kna1 occurs0.

    select kunnr land1 name1

    from kna1

    into corresponding fieldsoftable lt_kna1

    where land1 = p_land1.

    if sy-subrc eq0.

    loopat lt_kna1.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM50:

    REPORT Z9AMPROGRAM50.

    parameters : p_land1 type kna1-land1.

    data : lt_kna1 like kna1 occurs0.

    *data : begin of wa_kna1.

    * include structure kna1.

  • 7/30/2019 Core Abap Notes With Programs

    39/294

    39 | P a g e S a n t o s h P

    *data : end of wa_kna1.

    data : wa_kna1 like kna1.

    select kunnr land1 name1

    from kna1

    into corresponding fieldsoftable lt_kna1

    where land1 = p_land1.

    if sy-subrc eq0.

    loopat lt_kna1 into wa_kna1.

    write :/ wa_kna1-kunnr,

    wa_kna1-land1,

    wa_kna1-name1.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM51:

    REPORT Z9AMPROGRAM51.

    tables : kna1.

  • 7/30/2019 Core Abap Notes With Programs

    40/294

    40 | P a g e S a n t o s h P

    parameters : p_land1 type kna1-land1.

    data : lt_kna1 like kna1 occurs0.

    **field-symbols like line of lt_kna1.

    field-symbols type kna1.

    select kunnr land1 name1

    from kna1

    into corresponding fieldsoftable lt_kna1

    where land1 = p_land1.

    if sy-subrc eq0.

    loopat lt_kna1 assigning .

    write :/ -kunnr,

    -land1,

    -name1.

    endloop.

    else.write :/ 'No data'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    41/294

    41 | P a g e S a n t o s h P

    Z9AMPROGRAM52:

    REPORT Z9AMPROGRAM52.

    parameters : p_land1 type kna1-land1.

    data : lt_kna1 like kna1 occurs0.

    data : wa_kna1 like kna1.

    select kunnr land1 name1

    from kna1

    into corresponding fieldsoftable lt_kna1

    where land1 = p_land1.

    if sy-subrc eq0.

    loopat lt_kna1 into wa_kna1.

    write :/ wa_kna1-kunnr,

    wa_kna1-land1,

    wa_kna1-name1.

    endloop.

    else.

    write :/ 'No data'.endif.

    loopat lt_kna1 into wa_kna1.

    if wa_kna1-name1 = 'srinivas'.

    wa_kna1-name1 = 'srinivas kumar'.

    modify lt_kna1 from wa_kna1.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    42/294

    42 | P a g e S a n t o s h P

    endloop.

    write :/ 'Redisplay after modification'.

    write :/ '*******************************'.

    skip1.

    loopat lt_kna1 into wa_kna1.

    write :/ wa_kna1-kunnr,

    wa_kna1-land1,

    wa_kna1-name1.

    endloop.

    Z9AMPROGRAM53:

    REPORT Z9AMPROGRAM53.

    parameters : p_land1 type kna1-land1.

    data : lt_kna1 like kna1 occurs0.

    field-symbols likelineof lt_kna1.

    select kunnr land1 name1

    from kna1

    into corresponding fieldsoftable lt_kna1

    where land1 = p_land1.

  • 7/30/2019 Core Abap Notes With Programs

    43/294

    43 | P a g e S a n t o s h P

    if sy-subrc eq0.

    loopat lt_kna1 assigning .

    write :/ -kunnr,

    -land1,

    -name1.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    loopat lt_kna1 assigning .

    if -name1 = 'srinivas'.

    -name1 = 'srinivas kumar'.

    endif.

    endloop.

    write :/ 'After modification'.

    write :/ '********************'.loopat lt_kna1 assigning .

    write :/ -kunnr,

    -land1,

    -name1.

    endloop.

  • 7/30/2019 Core Abap Notes With Programs

    44/294

    44 | P a g e S a n t o s h P

    Z9AMPROGRAM54:

    REPORT Z9AMPROGRAM54.

    tables kna1. "creates a default work area

    types : beginof ty_kna1,kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1

    withheaderline.

    select-options : so_land1 for kna1-land1.

    initialization.so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    append so_land1.

    start-of-selection.

    select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

    where land1 in so_land1.

    if sy-subrc eq0.

    loopat lt_kna1.

    * write :/ lt_kna1.

    write :/ lt_kna1-kunnr,

    lt_kna1-land1,

    lt_kna1-name1,

    lt_kna1-name2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    45/294

    45 | P a g e S a n t o s h P

    Z9AMPROGRAM55:

    REPORT Z9AMPROGRAM55.

    tables kna1. "creates a default work area

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1

    withheaderline.

    select-options : so_land1 for kna1-land1.

    initialization.

    so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    so_land1-sign = 'E'.

  • 7/30/2019 Core Abap Notes With Programs

    46/294

    46 | P a g e S a n t o s h P

    append so_land1.

    start-of-selection.

    select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

    where land1 in so_land1.

    if sy-subrc eq0.

    loopat lt_kna1.

    * write :/ lt_kna1.

    write :/ lt_kna1-kunnr,

    lt_kna1-land1,

    lt_kna1-name1,

    lt_kna1-name2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM56:

    REPORT Z9AMPROGRAM56.

    tables kna1. "creates a default work area

  • 7/30/2019 Core Abap Notes With Programs

    47/294

    47 | P a g e S a n t o s h P

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    select-options : so_land1 for kna1-land1.

    initialization.

    so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    append so_land1.

    start-of-selection.select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

    where land1 in so_land1.

    if sy-subrc eq0.

    loopat lt_kna1 into ls_kna1.

    write :/ ls_kna1-kunnr,

    ls_kna1-land1,

    ls_kna1-name1,

    ls_kna1-name2.

    endloop.

    else.write :/ 'No data'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    48/294

    48 | P a g e S a n t o s h P

    Z9AMPROGRAM57:

    REPORT Z9AMPROGRAM57.

    tables kna1. "creates a default work area

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    * ls_kna1 type ty_kna1.ls_kna1 likelineof lt_kna1.

    select-options : so_land1 for kna1-land1.

    initialization.

    so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    append so_land1.

    start-of-selection.

    select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

    where land1 in so_land1.

    if sy-subrc eq0.

    loopat lt_kna1 into ls_kna1.

    write :/ ls_kna1-kunnr,

    ls_kna1-land1,

  • 7/30/2019 Core Abap Notes With Programs

    49/294

    49 | P a g e S a n t o s h P

    ls_kna1-name1,

    ls_kna1-name2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM58:

    REPORT Z9AMPROGRAM58.

    tables kna1. "creates a default work area

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    gt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

  • 7/30/2019 Core Abap Notes With Programs

    50/294

    50 | P a g e S a n t o s h P

    select-options : so_land1 for kna1-land1.

    initialization.

    so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    append so_land1.

    start-of-selection.

    select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

    where land1 in so_land1.

    if sy-subrc eq0.

    describetable lt_kna1.

    write :/ 'No of records in lt_kna1 :',sy-tfill.

    else.

    write :/ 'No data'.

    endif.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 :',sy-tfill.

    loopat lt_kna1 into ls_kna1.

    append ls_kna1 to gt_kna1.

    endloop.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 after copying:',sy-tfill.

  • 7/30/2019 Core Abap Notes With Programs

    51/294

    51 | P a g e S a n t o s h P

    Z9AMPROGRAM59:

    REPORT Z9AMPROGRAM59.

    tables kna1. "creates a default work area

    types : beginof ty_kna1,kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    gt_kna1 typestandardtableof ty_kna1.

    * ls_kna1 type ty_kna1.

    select-options : so_land1 for kna1-land1.

    initialization.

    so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    append so_land1.

    start-of-selection.

    select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

    where land1 in so_land1.

    if sy-subrc eq0.

    describetable lt_kna1.

    write :/ 'No of records in lt_kna1 :',sy-tfill.

    else.

    write :/ 'No data'.

    endif.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 :',sy-tfill.

    *gt_kna1[] = lt_kna1[].

    appendlinesof lt_kna1 to gt_kna1.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 after copying:',sy-tfill.

  • 7/30/2019 Core Abap Notes With Programs

    52/294

    52 | P a g e S a n t o s h P

    Z9AMPROGRAM60:

    REPORT Z9AMPROGRAM60.

    tables kna1. "creates a default work area

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    gt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    select-options : so_land1 for kna1-land1.

    initialization.

    so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    append so_land1.

    start-of-selection.

    select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

  • 7/30/2019 Core Abap Notes With Programs

    53/294

    53 | P a g e S a n t o s h P

    where land1 in so_land1.

    if sy-subrc eq0.

    describetable lt_kna1.

    write :/ 'No of records in lt_kna1 :',sy-tfill.

    else.

    write :/ 'No data'.

    endif.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 :',sy-tfill.

    appendlinesof lt_kna1 from100to200to gt_kna1.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 after copying:',sy-tfill.

    Z9AMPROGRAM61:

    REPORT Z9AMPROGRAM61.

    tables kna1. "creates a default work area

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    name2 type kna1-name2,

    endof ty_kna1.

  • 7/30/2019 Core Abap Notes With Programs

    54/294

    54 | P a g e S a n t o s h P

    data : lt_kna1 typestandardtableof ty_kna1,

    gt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    select-options : so_land1 for kna1-land1.

    initialization.

    so_land1-low = 'AR'.

    so_land1-high = 'IN'.

    append so_land1.

    start-of-selection.

    select kunnr land1 name1 name2

    from kna1

    intotable lt_kna1

    where land1 in so_land1.

    if sy-subrc eq0.describetable lt_kna1.

    write :/ 'No of records in lt_kna1 :',sy-tfill.

    else.

    write :/ 'No data'.

    endif.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 :',sy-tfill.

    loopat lt_kna1 into ls_kna1

    where land1 = 'IN'.

    append ls_kna1 to gt_kna1.endloop.

    describetable gt_kna1.

    write :/ 'No of records in gt_kna1 :',sy-tfill.

  • 7/30/2019 Core Abap Notes With Programs

    55/294

    55 | P a g e S a n t o s h P

    Z9AMPROGRAM62:

    REPORT Z9AMPROGRAM62.

    types : beginof ty_emp.

    includestructure zgenesisemp.

    types endof ty_emp.

    data : ls_emp type ty_emp.

    ls_emp-empno = 68.

    ls_emp-ename = 'kiran kumar'.

    *insert zgenesisemp from ls_emp.

    modify zgenesisemp from ls_emp.

    write :/ 'no of records affected :',sy-dbcnt.

    Z9AMPROGRAM63:

    REPORT Z9AMPROGRAM63.

    types : beginof ty_emp.

    includestructure zgenesisemp.

    types endof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

  • 7/30/2019 Core Abap Notes With Programs

    56/294

    56 | P a g e S a n t o s h P

    ls_emp-empno = 88.

    ls_emp-ename = 'vmashi'.

    append ls_emp to lt_emp.

    clear ls_emp.

    ls_emp-empno = 89.

    ls_emp-ename = 'abc'.

    append ls_emp to lt_emp.

    clear ls_emp.

    ls_emp-empno = 77.

    ls_emp-ename = 'vamshi kumar'.

    append ls_emp to lt_emp.

    *insert zgenesisemp from table lt_emp.

    *insert zgenesisemp from table lt_emp

    * accepting duplicate keys.

    modify zgenesisemp fromtable lt_emp.

    write :/ 'no of records affected :',sy-dbcnt.

    Z9AMPROGRAM64:

    REPORT Z9AMPROGRAM64.

    types : beginof ty_emp.

    includestructure zgenesisemp.

    types endof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

    select * from zgenesisemp intotable lt_emp.

    if sy-subrc eq0.

    write :/ 'No of records retrieved :',sy-dbcnt.

  • 7/30/2019 Core Abap Notes With Programs

    57/294

    57 | P a g e S a n t o s h P

    readtable lt_emp into ls_emp index1.

    if sy-subrc eq0.

    write :/ 'Record record is ',ls_emp-empno,

    ls_emp-ename.

    else.

    write :/ 'Read failed'.

    endif.

    clear ls_emp.

    readtable lt_emp into ls_emp withkey empno = 88.

    if sy-subrc eq0.

    write :/ 'Record with empno = 88 is ',ls_emp-empno,

    ls_emp-ename.

    else.

    write :/ 'Read failed'.

    endif.

    uline.

    * sort lt_emp by empno.sort lt_emp by empno descending.

    clear ls_emp.

    readtable lt_emp into ls_emp

    withkey empno = 17binarysearch.

    if sy-subrc eq0.

    write :/ 'Record with empno = 17 is ',ls_emp-empno,

    ls_emp-ename,

    ls_emp-empdesig.

    else.

    write :/ 'Read failed'.

    endif.

    uline.clear ls_emp.

    readtable lt_emp into ls_emp

    withkey empno = '90'binarysearch

    transporting ename.

    if sy-subrc eq0.

    write :/ 'Record with empno = 90 is ',ls_emp-empno,

    ls_emp-ename,

    ls_emp-empdesig.

    else.

    write :/ 'Read failed'.

    endif.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    58/294

    58 | P a g e S a n t o s h P

    Z9AMPROGRAM65:

    REPORT Z9AMPROGRAM65.

    types : beginof ty_emp.

    includestructure zgenesisemp.

    types endof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

    select * from zgenesisemp intotable lt_emp.

    if sy-subrc eq0.

    loopat lt_emp into ls_emp.

    write :/ 'Index is ',sy-tabix.

    endloop.endif.

  • 7/30/2019 Core Abap Notes With Programs

    59/294

    59 | P a g e S a n t o s h P

    Z9AMPROGRAM66:

    REPORT Z9AMPROGRAM66.

    do10times.

    write :/ 'Sy-tabix is ',sy-tabix,'sy-index is ',sy-index.

    enddo.

  • 7/30/2019 Core Abap Notes With Programs

    60/294

    60 | P a g e S a n t o s h P

    Z9AMPROGRAM67:REPORT Z9AMPROGRAM67.

    types : beginof ty_emp.

    includestructure zgenesisemp.

    types endof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

    select * from zgenesisemp intotable lt_emp.

    if sy-subrc eq0.loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

    endif.

    sort lt_emp by ename DESCENDING.

    write :/ 'Data after sorting'.

    write :/ '*****************'.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.endloop.

    deleteadjacentduplicatesfrom lt_emp

    comparing ename.

    write :/ 'Data after Deleting adjacent duplicates'.

    write :/ '*****************'.

  • 7/30/2019 Core Abap Notes With Programs

    61/294

    61 | P a g e S a n t o s h P

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

    Z9AMPROGRAM68:

    REPORT Z9AMPROGRAM68.

    types : beginof ty_emp.

    includestructure zgenesisemp.

    types endof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

    select * from zgenesisemp intotable lt_emp.

    if sy-subrc eq0.

    describetable lt_emp.

    write :/ 'No of records :',sy-tfill.

    endif.

    *clear lt_emp.

    refresh lt_emp.

  • 7/30/2019 Core Abap Notes With Programs

    62/294

    62 | P a g e S a n t o s h P

    describetable lt_emp.

    write :/ 'No of records after Refresh :',sy-tfill.

    Z9AMPROGRAM69:

    REPORT Z9AMPROGRAM69.

    types : beginof ty_dept.

    includestructure zgdept.

    typesendof ty_dept.

    data : lt_dept typestandardtableof ty_dept,

    ls_dept type ty_dept.

    types : beginof ty_emp.

    includestructure zgemp.

    typesendof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

    select * from zgdept intotable lt_dept.

    if sy-subrc eq0.

    loopat lt_dept into ls_dept.

    select * from zgemp intotable lt_emp

    where deptno = ls_dept-deptno.

    endloop.

    endif.

    loopat lt_dept into ls_dept.

    write :/ ls_dept-deptno,

    ls_dept-dname,ls_dept-loc.

    loopat lt_emp into ls_emp

    where deptno = ls_dept-deptno.

    write :/5 ls_emp-empno,

    ls_emp-ename,

    ls_emp-deptno.

  • 7/30/2019 Core Abap Notes With Programs

    63/294

    63 | P a g e S a n t o s h P

    endloop.

    endloop.

    Z9AMPROGRAM70:REPORT Z9AMPROGRAM70.

    types : beginof ty_dept.

    includestructure zgdept.

    typesendof ty_dept.

    data : lt_dept typestandardtableof ty_dept,

    ls_dept type ty_dept.

    types : beginof ty_emp.

    includestructure zgemp.typesendof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

    select * from zgdept intotable lt_dept.

    if sy-subrc eq0.

    loopat lt_dept into ls_dept.

    select * from zgemp

    appending corresponding fields

    oftable lt_emp

    where deptno = ls_dept-deptno.endloop.

    endif.

    loopat lt_dept into ls_dept.

    write :/ ls_dept-deptno,

    ls_dept-dname,

  • 7/30/2019 Core Abap Notes With Programs

    64/294

    64 | P a g e S a n t o s h P

    ls_dept-loc.

    loopat lt_emp into ls_emp

    where deptno = ls_dept-deptno.

    write :/5 ls_emp-empno,

    ls_emp-ename,

    ls_emp-deptno.

    endloop.

    endloop.

    Z9AMPROGRAM71:

    REPORT Z9AMPROGRAM71.

    types : beginof ty_dept.

    includestructure zgdept.

    typesendof ty_dept.

    data : lt_dept typestandardtableof ty_dept,

    ls_dept type ty_dept.

    types : beginof ty_emp.

    includestructure zgemp.

    typesendof ty_emp.

    data : lt_emp typestandardtableof ty_emp,

    ls_emp type ty_emp.

    select * from zgdept intotable lt_dept.

    if lt_dept isnotinitial.

    select * from zgemp intotable lt_emp

    forall entries in lt_dept

    where deptno = lt_dept-deptno.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    65/294

    65 | P a g e S a n t o s h P

    loopat lt_dept into ls_dept.

    write :/ ls_dept-deptno,

    ls_dept-dname,

    ls_dept-loc.

    loopat lt_emp into ls_emp

    where deptno = ls_dept-deptno.

    write :/5 ls_emp-empno,

    ls_emp-ename,

    ls_emp-deptno.

    endloop.

    endloop.

    Z9AMPROGRAM72:

    REPORT Z9AMPROGRAM72.

    tables mara.

    select-options so_matnr for mara-matnr.

    types : beginof ty_mara,

    matnr type mara-matnr,

    mtart type mara-mtart,

    matkl type mara-matkl,

    endof ty_mara.

    data : lt_mara typestandardtableof ty_mara,ls_mara type ty_mara.

    types : beginof ty_marc,

    matnr type marc-matnr,

    werks type marc-werks,

    pstat type marc-pstat,

  • 7/30/2019 Core Abap Notes With Programs

    66/294

    66 | P a g e S a n t o s h P

    endof ty_marc.

    data : lt_marc typestandardtableof ty_marc,

    ls_marc type ty_marc.

    types : beginof ty_t001w,

    werks type t001w-werks,

    name1 type t001w-name1,

    endof ty_t001w.

    data : lt_t001w typestandardtableof ty_t001w,

    ls_t001w type ty_t001w.

    types : beginof ty_final,

    matnr type mara-matnr,

    mtart type mara-mtart,

    werks type marc-werks,

    name1 type t001w-name1,

    endof ty_final.

    data : lt_final typestandardtableof ty_final,

    ls_final type ty_final.

    select matnr mtart matkl

    from mara

    intotable lt_mara

    where matnr in so_matnr.

    if lt_mara[] isnotinitial.

    select matnr werks pstat

    from marc

    intotable lt_marcforall entries in lt_mara

    where matnr = lt_mara-matnr.

    if lt_marc[] isnotinitial.

    select werks name1

    from t001w

    intotable lt_t001w

    forall entries in lt_marc

    where werks = lt_marc-werks.

    endif.

    endif.

    if lt_mara[] isnotinitial.

    if lt_marc[] isnotinitial.

    if lt_t001w[] isnotinitial.

    loopat lt_mara into ls_mara.

    write :/(110) ls_mara-matnr,

    ls_mara-mtart.

    loopat lt_marc into ls_marc

  • 7/30/2019 Core Abap Notes With Programs

    67/294

    67 | P a g e S a n t o s h P

    where matnr = ls_mara-matnr.

    write ls_marc-werks.

    loopat lt_t001w into ls_t001w

    where werks = ls_marc-werks.

    write ls_t001w-name1.

    endloop.

    endloop.

    endloop.

    endif.

    endif.

    endif.

    Z9AMPROGRAM73:REPORT Z9AMPROGRAM73.

    tables mara.

    select-options so_matnr for mara-matnr.

    types : beginof ty_mara,

    matnr type mara-matnr,

  • 7/30/2019 Core Abap Notes With Programs

    68/294

    68 | P a g e S a n t o s h P

    mtart type mara-mtart,

    matkl type mara-matkl,

    endof ty_mara.

    data : lt_mara typestandardtableof ty_mara,

    ls_mara type ty_mara.

    types : beginof ty_marc,

    matnr type marc-matnr,

    werks type marc-werks,

    pstat type marc-pstat,

    endof ty_marc.

    data : lt_marc typestandardtableof ty_marc,

    ls_marc type ty_marc.

    types : beginof ty_t001w,

    werks type t001w-werks,

    name1 type t001w-name1,endof ty_t001w.

    data : lt_t001w typestandardtableof ty_t001w,

    ls_t001w type ty_t001w.

    types : beginof ty_final,

    matnr type mara-matnr,

    mtart type mara-mtart,

    werks type marc-werks,

    name1 type t001w-name1,

    endof ty_final.

    data : lt_final typestandardtableof ty_final,

    ls_final type ty_final.

    select matnr mtart matkl

    from mara

    intotable lt_mara

    where matnr in so_matnr.

    if lt_mara[] isnotinitial.

    select matnr werks pstat

    from marc

    intotable lt_marc

    forall entries in lt_mara

    where matnr = lt_mara-matnr.

    if lt_marc[] isnotinitial.

    select werks name1

    from t001w

    intotable lt_t001w

  • 7/30/2019 Core Abap Notes With Programs

    69/294

    69 | P a g e S a n t o s h P

    forall entries in lt_marc

    where werks = lt_marc-werks.

    endif.

    endif.

    if lt_mara[] isnotinitial.

    if lt_marc[] isnotinitial.

    if lt_t001w[] isnotinitial.

    loopat lt_mara into ls_mara.

    ls_final-matnr = ls_mara-matnr.

    ls_final-mtart = ls_mara-mtart.

    loopat lt_marc into ls_marc

    where matnr = ls_mara-matnr.

    ls_final-werks = ls_marc-werks.

    loopat lt_t001w into ls_t001w

    where werks = ls_marc-werks.

    ls_final-name1 = ls_t001w-name1.

    append ls_final to lt_final.

    endloop.

    clear ls_final.endloop.

    endloop.

    endif.

    endif.

    endif.

    if lt_final[] isnotinitial.

    loopat lt_final into ls_final.

    write :/ ls_final-matnr,

    ls_final-mtart,

    ls_final-werks,

    ls_final-name1.skip1.

    endloop.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    70/294

    70 | P a g e S a n t o s h P

    Z9AMPROGRAM74:

    REPORT Z9AMPROGRAM74.

    parameters : p_land1 type kna1-land1

    default'IN'.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    select kunnr land1 name1

    from kna1

    into ls_kna1where land1 = 'IN'.

    write :/ ls_kna1-kunnr,

    ls_kna1-land1,

    ls_kna1-name1.

    endselect.

  • 7/30/2019 Core Abap Notes With Programs

    71/294

    71 | P a g e S a n t o s h P

    Z9AMPROGRAM75:

    REPORT Z9AMPROGRAM75.

    PARAMETERS : p_kunnr type kna1-kunnr.

    types : beginof ty_kna1,

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : ls_kna1 type ty_kna1.

    selectsingle land1 name1

    from kna1

    into ls_kna1

    where kunnr = p_kunnr.

    if sy-subrc eq0.

    write :/ ls_kna1-land1,

    ls_kna1-name1.

    else.

  • 7/30/2019 Core Abap Notes With Programs

    72/294

    72 | P a g e S a n t o s h P

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM76:

    REPORT Z9AMPROGRAM76.

    PARAMETERS : p_kunnr type kna1-kunnr.

    data : lv_land1 type kna1-land1,

    lv_name1 type kna1-name1.

    execsql.

    select land1 , name1 from kna1

    into :lv_land1, :lv_name1

    where kunnr = :p_kunnr

    *here we are giving period that's y it is giving runtime error

    endexec.

    if sy-subrc eq0.

    write :/ lv_land1,

    lv_name1.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    73/294

    73 | P a g e S a n t o s h P

    Z9AMPROGRAM77:

    REPORT Z9AMPROGRAM77.

    parameters : p_land1 type kna1-land1.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : ls_kna1 type ty_kna1.

    data abc typecursor.

    opencursor abc forselect kunnr land1 name1

    from kna1

    where land1 = p_land1.

    do.

    fetchnextcursor abc into ls_kna1.

    if sy-subrc eq0.

    write :/ ls_kna1-kunnr,ls_kna1-land1,

    ls_kna1-name1.

    else.

    exit.

    endif.

    enddo.

  • 7/30/2019 Core Abap Notes With Programs

    74/294

    74 | P a g e S a n t o s h P

    closecursor abc.

    Z9AMPROGRAM78:

    REPORT z9amprogram78.

    PARAMETERS : p_land1 TYPE kna1-land1.

    DATA :

    lv_kunnr TYPE kna1-kunnr,

    lv_land1 TYPE kna1-land1,

    lv_name1 TYPE kna1-name1.

    EXECSQL.

    open abc forselect kunnr, land1, name1

    from kna1

    where land1 = :p_land1

    ENDEXEC.

    DO.

  • 7/30/2019 Core Abap Notes With Programs

    75/294

    75 | P a g e S a n t o s h P

    EXECSQL.

    fetchnext abc into :lv_kunnr,:lv_land1,:lv_name1

    ENDEXEC.

    IF sy-subrc EQ0.

    WRITE :/ lv_kunnr,

    lv_land1,

    lv_name1.

    ELSE.

    EXIT.

    ENDIF.

    ENDDO.

    EXECSQL.

    close abc

    ENDEXEC.

    Z9AMPROGRAM79:

  • 7/30/2019 Core Abap Notes With Programs

    76/294

    76 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM79.

    ranges : r_land1 for kna1-land1.

    r_land1-low = 'AR'.

    r_land1-high = 'IN'.

    r_land1-option = 'BT'.

    r_land1-sign = 'I'.

    append r_land1.

    data : lt_kna1 type zcustttype,

    * ls_kna1 like line of lt_kna1,

    ls_kna1 type zcustltype.

    select kunnr land1 name1

    from kna1

    intotable lt_kna1

    where land1 in r_land1.

    if sy-subrc eq0.loopat lt_kna1 into ls_kna1.

    write :/ ls_kna1-kunnr,

    ls_kna1-land1,

    ls_kna1-name1.

    endloop.

    else.

    write :/ 'No data'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    77/294

    77 | P a g e S a n t o s h P

    Z9AMPROGRAM80:

    REPORT Z9AMPROGRAM80.

    type-pools : zcgrp,slis.

    write :/ zcgrp_x.

    data : lt_kna1 typestandardtableof

    zcgrp_ty_kna1,

    ls_kna1 type zcgrp_ty_kna1.

    types : beginof ty_kna1.

    includetype zcgrp_ty_kna1.

    types : name2 type kna1-name2,

    endof ty_kna1.

    data k type zcgrp_y.

    k = 20.

    write :/ k.

    datamtype slis_tabname.

    data gt_kna1 type zcgrp_kna1.

    Z9AMPROGRAM81:

    REPORT Z9AMPROGRAM81.

    types : beginof ty_count,

    cnttypei,

    endof ty_count.

    data : lt_count typestandardtableof ty_count.

    datacnttypei.

    selectcount(*) from zgemp

    intocnt

  • 7/30/2019 Core Abap Notes With Programs

    78/294

    78 | P a g e S a n t o s h P

    groupby deptno.

    write :/ cnt.

    endselect.

    Z9AMPROGRAM82:

    REPORT Z9AMPROGRAM82.

    datacnttypei.

    data dno type zgemp-deptno.

    selectcount(*) deptno from zgemp

    into (cnt,dno)

    groupby deptno.

    write :/ cnt,dno.

    endselect.

  • 7/30/2019 Core Abap Notes With Programs

    79/294

    79 | P a g e S a n t o s h P

    Z9AMPROGRAM83:

    REPORT Z9AMPROGRAM83.

    datacnttypei.

    data dno type zgemp-deptno.

    selectcount(*) deptno from zgemp

    into (cnt,dno)

    groupby deptno

    * where deptno ne 10.

    having deptno ne10.

    write :/ cnt,dno.

    endselect.

  • 7/30/2019 Core Abap Notes With Programs

    80/294

    80 | P a g e S a n t o s h P

    Z9AMPROGRAM84:

    REPORT Z9AMPROGRAM84.

    types : beginof ty_emp,

    empno typei,

    ename(20) typec,

    endof ty_emp.

    data : lt_emp typestandardtableof ty_emp

    with non-uniqueKEY empno,

    ls_emp type ty_emp.

    clear ls_emp.

    ls_emp-empno = 1.

    ls_emp-ename = 'Raju'.

    append ls_emp to lt_emp.

    clear ls_emp.

    ls_emp-empno = 3.

    ls_emp-ename = 'Ravi'.

    append ls_emp to lt_emp.

    clear ls_emp.

    ls_emp-empno = 2.ls_emp-ename = 'Ramu'.

    append ls_emp to lt_emp.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

  • 7/30/2019 Core Abap Notes With Programs

    81/294

    81 | P a g e S a n t o s h P

    endloop.

    sort lt_emp by empno.

    write :/ 'after sort'.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

    Z9AMPROGRAM85:

    REPORT Z9AMPROGRAM85.

    types : beginof ty_emp,

    empno typei,

    ename(20) typec,endof ty_emp.

    data : lt_emp typesortedtableof ty_emp

    with non-uniqueKEY empno,

    ls_emp type ty_emp.

    clear ls_emp.

    ls_emp-empno = 3.

    ls_emp-ename = 'Raju'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.ls_emp-empno = 1.

    ls_emp-ename = 'Ravi'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

  • 7/30/2019 Core Abap Notes With Programs

    82/294

    82 | P a g e S a n t o s h P

    ls_emp-empno = 2.

    ls_emp-ename = 'Ramu'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 1.

    ls_emp-ename = 'Ramesh'.

    insert ls_emp intotable lt_emp.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

    Z9AMPROGRAM86:

    REPORT Z9AMPROGRAM86.

    types : beginof ty_emp,

    empno typei,

    ename(20) typec,

    endof ty_emp.

    data : lt_emp typesortedtableof ty_emp

    withuniqueKEY empno ename,

    ls_emp type ty_emp.

    clear ls_emp.ls_emp-empno = 3.

    ls_emp-ename = 'Raju'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 1.

    ls_emp-ename = 'Ravi'.

  • 7/30/2019 Core Abap Notes With Programs

    83/294

    83 | P a g e S a n t o s h P

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 2.

    ls_emp-ename = 'Ramu'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 1.

    ls_emp-ename = 'Ramesh'.

    insert ls_emp intotable lt_emp.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

    Z9AMPROGRAM87:

    REPORT Z9AMPROGRAM87.

    types : beginof ty_emp,

    empno typei,

    ename(20) typec,

    endof ty_emp.

    data : lt_emp typesortedtableof ty_emp

    withuniqueKEY empno ename,

    ls_emp type ty_emp.

    clear ls_emp.

    ls_emp-empno = 3.

    ls_emp-ename = 'Raju'.

    insert ls_emp intotable lt_emp.

  • 7/30/2019 Core Abap Notes With Programs

    84/294

    84 | P a g e S a n t o s h P

    clear ls_emp.

    ls_emp-empno = 1.

    ls_emp-ename = 'Ravi'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 2.

    ls_emp-ename = 'Ramu'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 1.

    ls_emp-ename = 'Ramesh'.

    insert ls_emp intotable lt_emp.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

    write :/ '*****************'.

    clear ls_emp.

    readtable lt_emp into ls_emp index2.

    if sy-subrc eq0.

    write :/ ls_emp-empno,

    ls_emp-ename.

    else.

    write :/ 'No record'.

    endif.

    write :/ '*****************'.clear ls_emp.

    readtable lt_emp into ls_emp

    withkey empno = 1.

    if sy-subrc eq0.

    write :/ ls_emp-empno,

    ls_emp-ename.

    else.

    write :/ 'No record'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    85/294

    85 | P a g e S a n t o s h P

    Z9AMPROGRAM88:

    REPORT Z9AMPROGRAM88.

    types : beginof ty_emp,

    empno typei,

    ename(20) typec,

    endof ty_emp.

    data : lt_emp typehashedtableof ty_emp

    withuniquekey empno,

    ls_emp type ty_emp.

    clear ls_emp.

    ls_emp-empno = 3.ls_emp-ename = 'raju'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 1.

    ls_emp-ename = 'ravi'.

    insert ls_emp intotable lt_emp.

    clear ls_emp.

    ls_emp-empno = 2.

    ls_emp-ename = 'ramu'.

    insert ls_emp intotable lt_emp.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

  • 7/30/2019 Core Abap Notes With Programs

    86/294

    86 | P a g e S a n t o s h P

    sort lt_emp.

    write :/ 'After sort'.

    loopat lt_emp into ls_emp.

    write :/ ls_emp-empno,

    ls_emp-ename.

    endloop.

    write :/ '****************'.

    clear ls_emp.

    readtable lt_emp into ls_emp withkey empno = 1.

    if sy-subrc eq0.

    write :/ ls_emp-empno,

    ls_emp-ename.

    else.

    write :/ 'No record'.

    endif.

    Z9AMPROGRAM89:

    REPORT Z9AMPROGRAM89.

    data : beginof wa,

    deptno(3) typec,

    ename(20) typec,

    empsal typei,

    endof wa.

    data : lt_emp likesortedtableof wa

    with non-uniquekey deptno ename.

    clear wa.

    wa-deptno = 'a1'.

  • 7/30/2019 Core Abap Notes With Programs

    87/294

    87 | P a g e S a n t o s h P

    wa-ename = 'raju'.

    wa-empsal = 1000.

    insert wa intotable lt_emp.

    clear wa.

    wa-deptno = 'a2'.

    wa-ename = 'ravi'.

    wa-empsal = 2000.

    insert wa intotable lt_emp.

    clear wa.

    wa-deptno = 'a1'.

    wa-ename = 'raju'.

    wa-empsal = 3000.

    insert wa intotable lt_emp.

    loopat lt_emp into wa.

    write :/ wa-deptno,

    wa-ename,wa-empsal.

    endloop.

    Z9AMPROGRAM90:

    REPORT Z9AMPROGRAM90.

    data : beginof wa,

    deptno(3) typec,

    ename(20) typec,

    empsal typei,

    endof wa.

    data : lt_emp likesortedtableof wa

    with non-uniquekey deptno ename.

    clear wa.

    wa-deptno = 'a1'.

  • 7/30/2019 Core Abap Notes With Programs

    88/294

    88 | P a g e S a n t o s h P

    wa-ename = 'raju'.

    wa-empsal = 1000.

    collect wa into lt_emp.

    clear wa.

    wa-deptno = 'a2'.

    wa-ename = 'ravi'.

    wa-empsal = 2000.

    collect wa into lt_emp.

    clear wa.

    wa-deptno = 'a1'.

    wa-ename = 'raju'.

    wa-empsal = 3000.

    collect wa into lt_emp.

    loopat lt_emp into wa.

    write :/ wa-deptno,

    wa-ename,wa-empsal.

    endloop.

    Z9AMPROGRAM91:

    REPORT Z9AMPROGRAM91.

    data : beginof wa,

    deptno(3) typec,

    ename(20) typec,

    empsal typei,

    endof wa.

    data : lt_emp likestandardtableof wa.

    clear wa.

    wa-deptno = 'a1'.

    wa-ename = 'raju'.

    wa-empsal = 1000.

  • 7/30/2019 Core Abap Notes With Programs

    89/294

    89 | P a g e S a n t o s h P

    append wa to lt_emp.

    clear wa.

    wa-deptno = 'a2'.

    wa-ename = 'ravi'.

    wa-empsal = 2000.

    append wa to lt_emp.

    clear wa.

    wa-deptno = 'a1'.

    wa-ename = 'raju'.

    wa-empsal = 3000.

    append wa to lt_emp.

    loopat lt_emp into wa.

    write :/ wa-deptno,

    wa-ename,wa-empsal.

    endloop.

    Z9AMPROGRAM92:

    REPORT Z9AMPROGRAM92.

    data : beginof wa,

    deptno(3) typec,

    ename(20) typec,

    empsal typei,

    endof wa.

    data : lt_emp likestandardtableof wa.

    clear wa.

    wa-deptno = 'a1'.

    wa-ename = 'raju'.

  • 7/30/2019 Core Abap Notes With Programs

    90/294

    90 | P a g e S a n t o s h P

    wa-empsal = 1000.

    collect wa into lt_emp.

    clear wa.

    wa-deptno = 'a2'.

    wa-ename = 'ravi'.

    wa-empsal = 2000.

    collect wa into lt_emp.

    clear wa.

    wa-deptno = 'a1'.

    wa-ename = 'raju'.

    wa-empsal = 3000.

    collect wa into lt_emp.

    loopat lt_emp into wa.

    write :/ wa-deptno,

    wa-ename,

    wa-empsal.endloop.

    Z9AMPROGRAM93:

    REPORT Z9AMPROGRAM93.

    *message i900(z9ammsg) with 'information'.

    *message s902(z9ammsg) with 'status'.

    *message w903(z9ammsg) with 'warning'.

    *message a904(z9ammsg) with 'abort'.

    message e901(z9ammsg) with'error'.

    Z9AMPROGRAM94:

  • 7/30/2019 Core Abap Notes With Programs

    91/294

  • 7/30/2019 Core Abap Notes With Programs

    92/294

    92 | P a g e S a n t o s h P

    loc type zgdept-loc,

    endof ty_emp_dept.

    data : lt_emp_dept typestandardtableof

    ty_emp_dept,

    ls_emp_dept type ty_emp_dept.

    select * from zgemp asx

    inner join zgdept as y

    onx~deptno = y~deptno

    intotable lt_emp_dept.

    if sy-subrc eq0.

    loopat lt_emp_dept into ls_emp_dept.

    write :/ ls_emp_dept-empno,

    (10) ls_emp_dept-ename,

    ls_emp_dept-deptno,

    ls_emp_dept-v_deptno,

    ls_emp_dept-dname,

    ls_emp_dept-loc.skip2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM96:

    REPORT Z9AMPROGRAM96.

    types : beginof ty_emp_dept.

    includestructure zgemp.

    types : v_deptno type zgdept-deptno,

    dname type zgdept-dname,

    endof ty_emp_dept.

    data : lt_emp_dept typestandardtableof

    ty_emp_dept,

    ls_emp_dept type ty_emp_dept.

  • 7/30/2019 Core Abap Notes With Programs

    93/294

    93 | P a g e S a n t o s h P

    select empno ename x~deptno y~deptno dname

    from zgemp asx

    inner join zgdept as y

    onx~deptno = y~deptno

    intotable lt_emp_dept.

    if sy-subrc eq0.

    loopat lt_emp_dept into ls_emp_dept.

    write :/ ls_emp_dept-empno,

    (10) ls_emp_dept-ename,

    ls_emp_dept-deptno,

    ls_emp_dept-v_deptno,

    ls_emp_dept-dname.

    skip2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM97:

  • 7/30/2019 Core Abap Notes With Programs

    94/294

    94 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM97.

    types : beginof ty_emp_dept.

    includestructure zgemp.

    types : v_deptno type zgdept-deptno,

    dname type zgdept-dname,

    endof ty_emp_dept.

    data : lt_emp_dept typestandardtableof

    ty_emp_dept,

    ls_emp_dept type ty_emp_dept.

    select empno ename zgemp~deptno zgdept~deptno dname

    from zgemp

    inner join zgdept

    on zgemp~deptno = zgdept~deptno

    intotable lt_emp_dept.

    if sy-subrc eq0.

    loopat lt_emp_dept into ls_emp_dept.write :/ ls_emp_dept-empno,

    (10) ls_emp_dept-ename,

    ls_emp_dept-deptno,

    ls_emp_dept-v_deptno,

    ls_emp_dept-dname.

    skip2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    95/294

    95 | P a g e S a n t o s h P

    Z9AMPROGRAM98:

    REPORT Z9AMPROGRAM98.

    types : beginof ty_emp_dept.

    includestructure zgemp.

    types : v_deptno type zgdept-deptno,

    dname type zgdept-dname,

    endof ty_emp_dept.

    data : lt_emp_dept typestandardtableof

    ty_emp_dept,ls_emp_dept type ty_emp_dept.

    select empno ename zgemp~deptno zgdept~deptno dname

    from zgemp

    inner join zgdept

    on zgemp~deptno = zgdept~deptno

  • 7/30/2019 Core Abap Notes With Programs

    96/294

    96 | P a g e S a n t o s h P

    intotable lt_emp_dept

    where zgemp~deptno ne10.

    if sy-subrc eq0.

    loopat lt_emp_dept into ls_emp_dept.

    write :/ ls_emp_dept-empno,

    (10) ls_emp_dept-ename,

    ls_emp_dept-deptno,

    ls_emp_dept-v_deptno,

    ls_emp_dept-dname.

    skip2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

    Z9AMPROGRAM99:

  • 7/30/2019 Core Abap Notes With Programs

    97/294

    97 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM99.

    types : beginof ty_emp_dept.

    includestructure zgemp.

    types : v_deptno type zgdept-deptno,

    dname type zgdept-dname,

    endof ty_emp_dept.

    data : lt_emp_dept typestandardtableof

    ty_emp_dept,

    ls_emp_dept type ty_emp_dept.

    select empno ename zgemp~deptno zgdept~deptno dname

    from zgemp

    left outer join zgdept

    on zgemp~deptno = zgdept~deptno

    intotable lt_emp_dept.

    if sy-subrc eq0.

    loopat lt_emp_dept into ls_emp_dept.write :/ ls_emp_dept-empno,

    (10) ls_emp_dept-ename,

    ls_emp_dept-deptno,

    ls_emp_dept-v_deptno,

    ls_emp_dept-dname.

    skip2.

    endloop.

    else.

    write :/ 'No data'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    98/294

    98 | P a g e S a n t o s h P

    Z9AMPROGRAM100:

    REPORT Z9AMPROGRAM100.

    write :/ 'welcome'.

    write :/ 'hello'.

    write :/ 'hai'.

    write :/ 'welcome'.

    write :/ 'hello'.

    write :/ 'bye'.

    write :/ 'welcome'.

    write :/ 'hello'.

  • 7/30/2019 Core Abap Notes With Programs

    99/294

    99 | P a g e S a n t o s h P

    Z9AMPROGRAM101:

    REPORT Z9AMPROGRAM101.

    write :/ 'begin'.

    perform abc.

    write :/ 'hello'.

    perform abc.

    write :/ 'bye'.

    perform abc.

    form abc.

    write :/ 'welcome'.

    write :/ 'hello'.

    endform.

  • 7/30/2019 Core Abap Notes With Programs

    100/294

    100 | P a g e S a n t o s h P

    Z9AMPROGRAM102:

    REPORT Z9AMPROGRAM102.

    perform abc(z9ampool).

    perform pqr(z9ampool).

    write :/ 'hello'.

    Z9AMPOOL:(SUBROUTINE)

    PROGRAM Z9AMPOOL.

    data : xtypeivalue10,

    y typeivalue5,

    ztypei.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : ls_kna1 type ty_kna1.

    * lt_kna1 type table of ty_kna1.

    form abc.

    z = x + y.

    write :/ 'sum is ',z.

    endform.

    form pqr.z = x - y.

    write :/ 'difference is ',z.

    endform.

    form lmn tables gt_kna1 structure ls_kna1.

    delete gt_kna1 where land1 = 'AR'.

    endform.

  • 7/30/2019 Core Abap Notes With Programs

    101/294

    101 | P a g e S a n t o s h P

    Z9AMPROGRAM103:

    REPORT Z9AMPROGRAM103.

    data : xtypeivalue10,

    y typeivalue20.

    write :/ 'X and Y before subroutine',x,y.

    perform abc usingx y. "actual parameters

    form abc.

    endform.

    Z9AMPROGRAM104:

    REPORT Z9AMPROGRAM104.

    data : xtypeivalue10,

    y typeivalue20.

    write :/ 'X and Y before subroutine',x,y.

    perform abc usingx y. "actual parameters

    write :/ 'X and Y after subroutine',x,y.

    form abc usingm n. "formal parameters

    dataztypei. "local variable

    z = m.

    m = n.

    n = z.endform.

  • 7/30/2019 Core Abap Notes With Programs

    102/294

    102 | P a g e S a n t o s h P

    Z9AMPROGRAM105:

    REPORT Z9AMPROGRAM105.

    data : xtypeivalue10,

    y typeivalue20.

    write :/ 'X and Y before subroutine',x,y.

    perform abc usingx y. "actual parameters

    write :/ 'X and Y after subroutine',x,y.

    form abc usingvalue(m) value(n). "formal parameters

    dataztypei. "local variable

    z = m.

    m = n.

    n = z.

    endform.

    Z9AMPROGRAM106:

    REPORT Z9AMPROGRAM106.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

  • 7/30/2019 Core Abap Notes With Programs

    103/294

    103 | P a g e S a n t o s h P

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    select kunnr land1 name1

    from kna1

    intotable lt_kna1

    where land1 in ('AR','IN').

    if sy-subrc eq0.

    describetable lt_kna1.

    write :/ 'No of records before sub:',sy-tfill.

    perform abc tables lt_kna1.

    describetable lt_kna1.

    write :/ 'No of records after sub:',sy-tfill.

    endif.

    form abc tables gt_kna1 structure ls_kna1.

    delete gt_kna1 where land1 = 'AR'.

    endform.

    Z9AMPROGRAM107:

    REPORT Z9AMPROGRAM107.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1.

  • 7/30/2019 Core Abap Notes With Programs

    104/294

    104 | P a g e S a n t o s h P

    select kunnr land1 name1

    from kna1

    intotable lt_kna1

    where land1 in ('AR','IN').

    if sy-subrc eq0.

    describetable lt_kna1.

    write :/ 'No of records before sub:',sy-tfill.

    perform lmn(z9ampool) tables lt_kna1 .

    describetable lt_kna1.

    write :/ 'No of records after sub:',sy-tfill.

    endif.

    Z9AMPOOL:

    *&---------------------------------------------------------------------*

    *& Subroutine Pool Z9AMPOOL*&

    *&---------------------------------------------------------------------*

    *&

    *&

    *&---------------------------------------------------------------------*

    PROGRAM Z9AMPOOL.

    data : xtypeivalue10,

    y typeivalue5,

    ztypei.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : ls_kna1 type ty_kna1.

    * lt_kna1 type table of ty_kna1.

    form abc.

    z = x + y.

    write :/ 'sum is ',z.

    endform.

    form pqr.

    z = x - y.

    write :/ 'difference is ',z.

    endform.

  • 7/30/2019 Core Abap Notes With Programs

    105/294

    105 | P a g e S a n t o s h P

    form lmn tables gt_kna1 structure ls_kna1.

    delete gt_kna1 where land1 = 'AR'.

    endform.

    Z9AMPROGRAM108:

    REPORT Z9AMPROGRAM108.

    data : xtypeivalue10,y typeivalue20,

    ztypei,

    z1 typei.

    write :/ 'Z is ',z.

    write :/ 'Z1 is ',z1.

    perform abc usingx y z z1.

    write :/ 'Z is ',z.

    write :/ 'Z1 is ',z1.

    form abc usingm n r r1.

    r = m + n.

    r1 = m * n.

    endform.

  • 7/30/2019 Core Abap Notes With Programs

    106/294

    106 | P a g e S a n t o s h P

    Z9AMPROGRAM109:

    REPORT Z9AMPROGRAM109.

    data : xtypeivalue10,

    y typeivalue20,

    ztypei,z1 typei.

    write :/ 'Z is ',z.

    write :/ 'Z1 is ',z1.

    perform abc usingx y changingz z1.

    write :/ 'Z is ',z.

    write :/ 'Z1 is ',z1.

    form abc usingm n changingvalue(r) value(r1).r = m + n.

    r1 = m * n.

    endform.

    Z9AMPROGRAM110:

    REPORT Z9AMPROGRAM110.

    data : xtypeivalue10,

    y typeivalue20,

    ztypei,

    z1 typei.

    write :/ 'Z is ',z.

    write :/ 'Z1 is ',z1.

    perform abc usingx y z z1.

  • 7/30/2019 Core Abap Notes With Programs

    107/294

    107 | P a g e S a n t o s h P

    write :/ 'Z is ',z.

    write :/ 'Z1 is ',z1.

    write :/ 'X is ',x.

    write :/ 'Y is ',y.

    form abc usingvalue(m) value(n) r r1.

    r = m + n.

    r1 = m * n.

    m = 30.

    n = 40.

    endform.

    Z9AMPROGRAM111:

    REPORT Z9AMPROGRAM111.

    parameters : p_land1 type kna1-land1.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    describetable lt_kna1.write :/ 'No of records :',sy-tfill.

    perform abc tables lt_kna1 using p_land1.

    describetable lt_kna1.

    write :/ 'No of records :',sy-tfill.

  • 7/30/2019 Core Abap Notes With Programs

    108/294

    108 | P a g e S a n t o s h P

    form abc tables gt_kna1 structure ls_kna1 using i_land1.

    select kunnr land1 name1

    from kna1

    intotable gt_kna1

    where land1 = i_land1.

    endform.

    Z9AMPROGRAM112:

    REPORT Z9AMPROGRAM112.

    parameters : p_land1 type kna1-land1.

    types : beginof ty_kna1,

    kunnr type kna1-kunnr,

    land1 type kna1-land1,

    name1 type kna1-name1,

    endof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    describetable lt_kna1.

    write :/ 'No of records :',sy-tfill.

    perform abc tables lt_kna1 changing p_land1.

    describetable lt_kna1.

  • 7/30/2019 Core Abap Notes With Programs

    109/294

    109 | P a g e S a n t o s h P

    write :/ 'No of records :',sy-tfill.

    form abc tables gt_kna1 structure ls_kna1 changing i_land1.

    select kunnr land1 name1

    from kna1

    intotable gt_kna1

    where land1 = i_land1.

    endform.

    Z9AMPROGRAM113:

    data : xtypei,y typei,

    ztypei.

    form abc.

    write :/ 'inside abc'.

    endform.

    Z9AMPROGRAM114:

  • 7/30/2019 Core Abap Notes With Programs

    110/294

    110 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM114.

    include z9amprogram113.

    x = 10.

    y = 20.

    z = x + y.

    writez.

    Z9AMPROGRAM115:

    REPORT Z9AMPROGRAM115.

    include Z9AMPROGRAM113.

    start-of-selection.

    perform abc.

    Z9AMPROGRAM116:

    REPORT Z9AMPROGRAM116.

    parameters : p_x typei,

    p_y typei.

    data r typei.

    CALLFUNCTION'Z930FM1'

    EXPORTING

    I_X = p_x

    I_Y = p_y.

    * IMPORTING

    * E_Z = r.

  • 7/30/2019 Core Abap Notes With Programs

    111/294

    111 | P a g e S a n t o s h P

    *

    r = p_x + p_y.

    write :/ 'sum is ',r.

    FUNCTION MODULE Z930FM1:

  • 7/30/2019 Core Abap Notes With Programs

    112/294

    112 | P a g e S a n t o s h P

    OUTPUT:

    Z9AMPROGRAM117:

    REPORT Z9AMPROGRAM117.

    data : i_x typei,

    i_y typei.

  • 7/30/2019 Core Abap Notes With Programs

    113/294

    113 | P a g e S a n t o s h P

    data: K_Z typei.

    CALLFUNCTION'ZFUN'.

    * EXPORTING

    * I_X = 10

    * I_Y = 20

    * IMPORTING

    * E_Z = K_Z.

    K_Z = I_X + I_Y.

    write : / 'Sum is ',K_Z.

    FUNCTION MODULE ZFUN:

  • 7/30/2019 Core Abap Notes With Programs

    114/294

    114 | P a g e S a n t o s h P

    OUTPUT:

    Z9AMPROGRAM118:

    REPORT Z9AMPROGRAM118.

    parameters : p_land1 type kna1-land1.

    types : beginof ty_kna1.

    includestructure zcstype.typesendof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    CALLFUNCTION'Z930FM3'

  • 7/30/2019 Core Abap Notes With Programs

    115/294

    115 | P a g e S a n t o s h P

    EXPORTING

    i_land1 = p_land1

    tables

    t_kna1 = lt_kna1.

    if lt_kna1[] isnotinitial.

    loopat lt_kna1 into ls_kna1.

    write :/ ls_kna1-kunnr,

    ls_kna1-land1,

    ls_kna1-name1.

    endloop.

    else.

    message'No data'type'I'.

    endif.

    FUNCTION MODULE Z930FM3:

  • 7/30/2019 Core Abap Notes With Programs

    116/294

    116 | P a g e S a n t o s h P

    OUTPUT:

  • 7/30/2019 Core Abap Notes With Programs

    117/294

    117 | P a g e S a n t o s h P

    9AMPROGRAM119:

    REPORT Z9AMPROGRAM119.

    parameters : p_land1 type kna1-land1.

    types : beginof ty_kna1.

    includestructure zcstype.

    typesendof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1,

    ls_kna1 type ty_kna1.

    CALLFUNCTION'Z930FM4'

    EXPORTING

    i_land1 = p_land1

    changing

    t_kna1 = lt_kna1.

    if lt_kna1[] isnotinitial.

    loopat lt_kna1 into ls_kna1.

    write :/ ls_kna1-kunnr,

    ls_kna1-land1,

    ls_kna1-name1.

    endloop.

    else.

    message'No data'type'I'.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    118/294

    118 | P a g e S a n t o s h P

    FUNCTION MODULE Z930FM4:

  • 7/30/2019 Core Abap Notes With Programs

    119/294

    119 | P a g e S a n t o s h P

    OUTPUT:

  • 7/30/2019 Core Abap Notes With Programs

    120/294

    120 | P a g e S a n t o s h P

    Z9AMPROGRAM120:

    REPORT Z9AMPROGRAM120.

    types : beginof ty_kna1.

    includestructure zcstype.

    typesendof ty_kna1.

    data : lt_kna1 typestandardtableof ty_kna1.

    select kunnr land1 name1

    from kna1

    intotable lt_kna1

    where land1 in ('AR','IN').

    if sy-subrc eq0.

    describetable lt_kna1.

    write :/ 'No of records :',sy-tfill.

    CALLFUNCTION'Z930FM5'

    CHANGINGt_kna1 = lt_kna1.

    describetable lt_kna1.

    write :/ 'No of records :',sy-tfill.

    endif.

  • 7/30/2019 Core Abap Notes With Programs

    121/294

    121 | P a g e S a n t o s h P

    FUNCTION MODULE Z930FM5:

    OUTPUT:

  • 7/30/2019 Core Abap Notes With Programs

    122/294

    122 | P a g e S a n t o s h P

    Z9AMPROGRAM121:

    REPORT Z9AMPROGRAM121.

    parameters : p_x typei,

    p_y typei.

    data r typei.

    CALLFUNCTION'Z930FM6'

    EXPORTING

    i_x = p_x

    i_y = p_y

    IMPORTING

    E_Z = r.

    write :/ 'Division is ',r.

    write :/ 'end'.

    FUNCTION MODULE Z930FM6:

  • 7/30/2019 Core Abap Notes With Programs

    123/294

    123 | P a g e S a n t o s h P

    OUTPUT:

  • 7/30/2019 Core Abap Notes With Programs

    124/294

    124 | P a g e S a n t o s h P

    Z9AMPROGRAM122:

    REPORT Z9AMPROGRAM122.

    parameters : p_x typei,p_y typei.

    data res typei.

    CALLFUNCTION'Z930FM7'

    EXPORTING

    i_x = p_x

    i_y = p_y

    IMPORTING

    E_Z = res

    EXCEPTIONS

    MYEXCEPTION = 1OTHERS = 2.

    if sy-subrc eq1.

    message'Cannot divide by zero'type'I'.

    elseif sy-subrc eq2.

    message'Unknown error'type'I'.

  • 7/30/2019 Core Abap Notes With Programs

    125/294

    125 | P a g e S a n t o s h P

    elseif sy-subrc eq0.

    write :/ 'Division is ',res.

    endif.

    FUNCTION MODULE Z930FM7:

  • 7/30/2019 Core Abap Notes With Programs

    126/294

    126 | P a g e S a n t o s h P

    OUTPUT:

    Z9AMPROGRAM123:

  • 7/30/2019 Core Abap Notes With Programs

    127/294

    127 | P a g e S a n t o s h P

    REPORT Z9AMPROGRAM123.

    define abc.

    &3 = &1 + &2.

    &4 = &1 - &2.

    end-of-definition.

    data : r1 typei,

    r2 typei.

    abc 2010 r1 r2.

    write :/ 'Sum is ',r1,

    / 'Difference is ',r2.

    abc 3016 r1 r2.

    write :/ 'Sum is ',r1,

    / 'Difference is ',r2.

    abc 8060 r1.

    ERROR:

    SELECTION SCREEN PROGRAMING

    Z9AMPROGRAM124:

    REPORT Z9AMPROGRAM124.

    include zmyinc.

    selection-screenbeginofblock b1

    withframetitle abc.

    selection-screenbeginofline.

    selection-screencomment6(20) lb1.parameters : p_empno type zemp200-empno

    default10.

    selection-screenendofline.

    selection-screenbeginofline.

    selection-screencomment6(20) lb2.

  • 7/30/2019 Core Abap Notes With Programs

    128/294

    128 | P a g e S a n t o s h P

    parameters : p_ename type zemp200-ename.

    selection-screenendofline.

    selection-screenbeginofline.

    selection-screencomment6(20) lb3.

    parameters p_desig type zemp200-empdesig.

    selection-screenendofline.

    selection-screenendofblock b1.

    selection-screenbeginofblock b2

    withframetitle pqr.

    selection-screenskip2.

    selection-screen pushbutton 5(10) bt1

    user-command p1.

    selection-screen pushbutton 18(10) bt2

    user-command p2.

    selection-screen pushbutton 31(10) bt3

    user-command p3.selection-screen pushbutton /5(10) bt4

    user-command p4.

    selection-screen pushbutton 18(10) bt5

    user-command p5.

    selection-screen pushbutton 31(10) bt6

    user-command p6.

    selection-screenendofblock b2.

    initialization.

    lb1 = 'Employee No'.

    lb2 = 'Employee Name'.

    lb3 = 'Employee Designation'.abc = 'Employee'.

    pqr = 'DB operations'.

    bt1 = 'Search'.

    bt2 = 'Insert'.

    bt3 = 'Delete'.

    bt4 = 'Modify'.

    bt5 = 'Clear'.

    bt6 = 'Exit'.

    at selection-screenoutput.

    if flag eq0.

    loopatscreen.

    ifscreen-name = 'LB2'or

    screen-name = 'LB3'or

    screen-name = 'P_ENAME'or

    screen-name = 'P_DESIG'.

    screen-invisible = '1'.

    screen-input = '0'.

  • 7/30/2019 Core Abap Notes With Programs

    129/294

    129 | P a g e S a n t o s h P

    modifyscreen.

    endif.

    endloop.

    elseif flag eq1.

    loopatscreen.

    ifscreen-name = 'LB2'or

    screen-name = 'LB3'or

    screen-name = 'P_ENAME'or

    screen-name = 'P_DESIG'.

    screen-invisible = '0'.

    screen-input = '1'.

    modifyscreen.

    endif.

    ifscreen-name = 'P_EMPNO'.

    screen-input = '0'.

    modifyscreen.

    endif.

    endloop.

    elseif flag = 2.loopatscreen.

    ifscreen-name = 'LB1'or

    screen-name = 'P_EMPNO'or

    screen-name = 'LB2'or

    screen-name = 'P_ENAME'or

    screen-name = 'LB3'or

    screen-name = 'P_DESIG'.

    screen-invisible = '0'.

    screen-input = '1'.

    modifyscreen.

    endif.endloop.

    endif.

    at selection-screen.

    case sy-ucomm.

    when'P6'.

    leaveprogram.

    when'P4'.

    if p_empno isnotinitial.

    performmodify.

    else.

    message'Please enter empno'type'I'.

    endif.

    endcase.

    at selection-screenon p_empno.

    if p_empno isnotinitial.

    perform getemployee using p_empno.

  • 7/30/2019 Core Abap Notes With Programs

    130/294

    130 | P a g e S a n t o s h P

    if ls_emp isnotinitial.

    p_ename = ls_emp-ename.

    p_desig = ls_emp-empdesig.

    flag = 1.

    else.

    message'Employee Not found'type'I'.

    endif.

    else.

    message'Please enter empno'type'I'.

    endif.

    at selection-screenonvalue-request for p_empno.

    perform getdata.

    if lt_emp[] isnotinitial.

    perform displayf4.

    endif.

    formmodify .clear ls_employee.

    ls_employee-empno = p_empno.

    ls_employee-ename = p_ename.

    ls_employee-empdesig = p_desig.

    modify zemp200 from ls_employee.

    if sy-subrc eq0.

    message'Record updated'type'I'.

    flag = 2.

    perform clearscreen.

    else.

    message'Record not updated'type'I'.

    endif.endform. " modify

    form clearscreen .

    clear : p_empno,

    p_ename,

    p_desig.

    endform. " clearscreen

  • 7/30/2019 Core Abap Notes With Programs

    131/294

    131 | P a g e S a n t o s h P

    Z9AMPROGRAM125:

    REPORT Z9AMPROGRAM125.

    selection-screenbeginof tabbed block tb1

    for5lines.

    selection-screen tab (10) t1 user-command p1.

    selection-screen tab (10) t2 user-command p2.

    selection-screenendof block tb1.

    selection-screen pushbutton 6(10) bt1

    user-command p3.

    selection-screen pushbutton 19(10) bt2user-command p4.

    selection-screenbeginofscreen100

    as subscreen.

    selection-screenbeginofline.

    selection-screencomment5(20) lb1.

    parameters : p_empno type zemp200-empno.

    selection-screenendofline.

    selection-screenbeginofline.selection-screencomment5(20) text-011.

    parameters : p_ename type zemp200-ename.

    selection-screenendofline.

    selection-screenendofscreen100.

  • 7/30/2019 Core Abap Notes With Programs

    132/294

    132 | P a g e S a n t o s h P

    selection-screenbeginofscreen200

    as subscreen.

    selection-screenbeginofline.

    selection-screencomment5(20) lb3.

    parameters : p_state type zemp200-empstate.

    selection-screenendofline.

    selection-screenbeginofline.

    selection-screencomment5(20) lb4.

    parameters : p_city type zemp200-empcity.

    selection-screenendofline.

    selection-screenendofscreen200.

    initialization.

    lb1 = 'Employee No'.

    * lb2 = text-002.lb3 = 'Employee state'.

    lb4 = 'Employee City'.

    bt1 = 'Insert'.

    bt2 = 'Exit'.

    t1 = 'First'.

    t2 = 'Second'.

    at selection-screen.

    case sy-ucomm.

    when'P1'.

    tb1-activetab = 'P1'.

    tb1-dynnr = '100'.tb1-prog = sy-repid.

    when'P2'.

    tb1-activetab = 'P2'.

    tb1-dynnr = '200'.

    tb1-prog = sy-repid.

    endcase.

  • 7/30/2019 Core Abap Notes With Programs

    133/294

    133 | P a g e S a n t o s h P

    Z9AMPROGRAM126:

    REPORT Z9AMPROGRAM126.

    tables sscrfields. "creates a default work area

    parametersxtypeidefault200.

    selection-screenfunctionkey1.

    selection-screenfunctionkey2.

    selection-screenfunctionkey3.

    selection-screenfunctionkey4.

    selection-screenfunctionkey5.

    initialization.sscrfields-functxt_01 = 'Button1'.

    sscrfields-functxt_02 = 'Button2'.

    sscrfields-functxt_03 = 'Button3'.

    sscrfields-functxt_04 = 'EXIT'.

    sscrfields-functxt_05 = 'BACK'.

    *

    at selection-screen.

  • 7/30/2019 Core Abap Notes With Programs

    134/294

    134 | P a g e S a n t o s h P

    case sy-ucomm.

    when'FC01'.

    message'Button1'type'I'.

    when'FC02'.

    message'Button2'type'I'.

    when'FC03'.

    leaveto list-processing.

    write :/ 'x=', x.

    when'FC04'.

    Leaveprogram.

    when'FC05'.

    Leaveprogram.

    endcase.

    Z9AMPROGRAM127:

    REPORT Z9AMPROGRAM127.

  • 7/30/2019 Core Abap Notes With Programs

    135/294

    135 | P a g e S a n t o s h P

    set pf-status 'ABC'.

    write :/ 'hello'.

    at user-command.

    case sy-ucomm.

    WHEN'BCK'.

    leaveprogram.

    when'P1'.

    message'Button1'type'I'.

    when'P2'.

    message'Button2'type'I'.

    endcase.

    SET PF-STATUSABC

  • 7/30/2019 Core Abap Notes With Programs

    136/294

    136 | P a g e S a n t o s h P

  • 7/30/2019 Core Abap Notes With Programs

    137/294

    137 | P a g e S a n t o s h P

    OUTPUT:

    MODULE POOL PROGRAMING

    METHOD 1:

    Z9AMPROGRAM128:

  • 7/30/2019 Core Abap Notes With Programs

    138/294

    138 | P a g e S a n t o s h P

  • 7/30/2019 Core Abap Notes With Programs

    139/294

    139 | P a g e S a n t o s h P

    SCREEN 100 LAYOUTS:

  • 7/30/2019 Core Abap Notes With Programs

    140/294

    140 | P a g e S a n t o s h P

  • 7/30/2019 Core Abap Notes With Programs

    141/294

    141 | P a g e S a n t o s h P

  • 7/30/2019 Core Abap Notes With Programs

    142/294

    142 | P a g e S a n t o s h P

  • 7/30/2019 Core Abap Notes With Programs

    143/294

    143 | P a g e S a n t o s h P

  • 7/30/2019 Core Abap Notes With Programs

    144/294

    144 | P a g e S a n t o s h P

    DRAG AND DROP THE FIELDS IN THE LAYOUT.

    SCREEN 200(SUBSCREEN) LAYOUTS:

  • 7/30/2019 Core Abap Notes With Programs

    145/294

    145 | P a g e S a n t o s h P

    SCREEN 300(SUBSCREEN) LAYOUTS:

  • 7/30/2019 Core Abap Notes With Programs

    146/294

    146 | P a g e S a n t o s h P

    SCREEN 400(SUBSCREEN) LAYOUTS:

  • 7/30/2019 Core Abap Notes With Programs

    147/294

    147 | P a g e S a n t o s h P

    LOW LOGIC OF SCREEN 100:

    PROCESS BEFORE OUTPUT.

    call subscreen ref1 including sy-repid scrno.

    MODULE abc.

    *PROCESS AFTER INPUT.

    call subscreen ref1.

    MODULE USER_COMMAND_0100.

    PBO:

    MODULE abc OUTPUT.

    set pf-status 'PQR'.

    ENDMODULE. " abc OUTPUT

    PAI:MODULE USER_COMMAND_0100 INPUT.

    case sy-ucomm.

    when'BACK'.

    leaveprogram.

    when'T3'.

    tbstr-activetab = 'T3'.

    SCRNO = '400'.

    when'P2'.

    tbstr-activetab = 'P2'.

    scrno = '300'.

    when'P1'.

    tbstr-activetab = 'P1'.

    scrno = '200'.

    when'P4'.

    leaveprogram.

    endcase.

    ENDMODULE.

  • 7/30/2019 Core Abap Notes With Programs

    148/294

    148 | P a g e S a n t o s h P

    LOW LOGIC OF SCREEN 200:

    PROCESS BEFORE OUTPUT.

    * MODULE STATUS_0200.

    *

    PROCESS AFTER INPUT.

    * MODULE USER_COMMAND_0200.

    LOW LOGIC OF SCREEN 300:

    PROCESS BEFORE