0% found this document useful (0 votes)
57 views35 pages

12th Sep 530pm Modulepool

This document contains code snippets and descriptions for multiple ABAP programs and includes. It defines data objects, modules, forms, and screen layouts for various user interactions and data processing. The modules handle input and output processing, as well as program logic and flow. Data is selected from database tables and displayed in screen fields and table controls.

Uploaded by

anilkumarpv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views35 pages

12th Sep 530pm Modulepool

This document contains code snippets and descriptions for multiple ABAP programs and includes. It defines data objects, modules, forms, and screen layouts for various user interactions and data processing. The modules handle input and output processing, as well as program logic and flow. Data is selected from database tables and displayed in screen fields and table controls.

Uploaded by

anilkumarpv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 35

530PM CORE ABAP OBJECTS:

PROGRAM73:

INCLUDE PROGRAM:

*&--------------------------------------------------------------------*
*& Include Z5PMTOP
Module
poo*
*&
*
*&--------------------------------------------------------------------*
program z5pmprog73
.
data : x type i,
io1 type i,
io2 type i,
io3 type i.
module user_command_1000 input.
case sy-ucomm.
when 'F2'.
leave program.
when 'F1'.
x = 12.

io3 = io1 + io2.


endcase.
endmodule.
" USER_COMMAND_1000
module status_1000 output.
io1 = 10.
io2 = 20.
if x = 0.
loop at screen.
if screen-name = 'LB3' or
screen-name = 'IO3'.
screen-invisible = '1'.
screen-input = '0'.
modify screen.
endif.
endloop.
*
else.
*
x = 1.
endif.
if x = 12.
loop at screen.
if screen-name = 'LB3' or
screen-name = 'IO3'.
screen-invisible = '0'.
screen-input = '1'.
modify screen.
endif.
endloop.
endif.

endmodule.

SCREEN100:

process before output.


module status_1000.
*
process after input.
module user_command_1000.

LAYOUT:

" STATUS_1000

OUTPUT

INPUT

TRANSACTION CODE:

PROGRAM74:

*&--------------------------------------------------------------------*
*& Module pool
Z530PMPROG74
*
*&
*
*&--------------------------------------------------------------------*
*&
*
*&
*
*&--------------------------------------------------------------------*
PROGRAM Z530PMPROG74
data : io1 type i,
io2 type i,
io3 type i.
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
when 'P1'.
io3 = io1 + io2.
when 'P2'.
leave program.
endcase.
ENDMODULE.

" USER_COMMAND_0100

INPUT

PROGRAM75:

*&--------------------------------------------------------------------*
*& Report Z530PMPROG75
*
*&
*
*&--------------------------------------------------------------------*
*&
*
*&
*
*&--------------------------------------------------------------------*
REPORT

Z530PMPROG75

write :/ 'hello'.
include z530pminc.
x = 10.
y = 20.
z = x + y.
write z.

Z530PMINC:

*&--------------------------------------------------------------------*
*& Include
Z530PMINC
*
*&--------------------------------------------------------------------*
data : x type i,
y type i,
z type i.

PROGRAM76:

*&--------------------------------------------------------------------*
*& Report Z530PMPROG76
*
*&
*
*&--------------------------------------------------------------------*
*&
*
*&
*
*&--------------------------------------------------------------------*
REPORT

Z530PMPROG76

perform abc.
include z530pminc1.

Z530PMINC1:
*&--------------------------------------------------------------------*
*& Include
Z530PMINC1
*
*&--------------------------------------------------------------------*
form abc.
write :/ 'inside abc'.
endform.

PROGRAM77:

*&--------------------------------------------------------------------*
*& Report Z530PMPROG77
*
*&
*
*&--------------------------------------------------------------------*
*&
*

*&
*
*&--------------------------------------------------------------------*
REPORT

Z530PMPROG77

include z530pminc1.
include z530pminc.
start-of-selection.
x = 20.
PERFOrm abc.

Z530PMINC1:
*&--------------------------------------------------------------------*
*& Include
Z530PMINC1
*
*&--------------------------------------------------------------------*
form abc.
write :/ 'inside abc'.
endform.

Z530PMINC:
*&--------------------------------------------------------------------*
*& Include
Z530PMINC
*
*&--------------------------------------------------------------------*
data : x type i,
y type i,
z type i.

PROGRAM78:

INCLUDE PROGRAM:

*&--------------------------------------------------------------------*
*& Include Z5PM78TOP
Module
poo*
*&
*
*&--------------------------------------------------------------------*
program z5pmprog78
.
tables kna1.
types : begin of ty_kna1.
include structure kna1.
*
kunnr type kna1-kunnr,
*
land1 type kna1-land1,
*
name1 type kna1-name1,
types : end of ty_kna1.
data : ls_kna1 type ty_kna1.
module user_command_1300 input.
case sy-ucomm.
when 'F2'.
leave program.
when 'F1'.
ls_kna1-kunnr = kna1-kunnr.

ls_kna1-land1 = kna1-land1.
ls_kna1-name1 = kna1-name1.
insert kna1 from ls_kna1.
if sy-subrc eq 0.
message 'record inserted' type 'I'.
else.
message 'record not inserted' type 'I'.
endif.
endcase.
endmodule.
module abc input.
case sy-ucomm.
when 'F3'.
leave program.
endcase.

" USER_COMMAND_1300

INPUT

endmodule.
" abc INPUT
module ghi input.
select single * from kna1 into kna1
where land1 = kna1-land1.
if sy-subrc ne 0.
message 'Please choose other country' type 'E'.
endif.
endmodule.

" ghi

SCREEN1300:

INPUT

process before output.


* MODULE STATUS_1300.
*
process after input.
*chain.
*field kna1-kunnr.
*field kna1-name1.
*field kna1-land1 values ('AD','IN').
*endchain.
field kna1-land1 module ghi.
module user_command_1300.
module abc at exit-command.

LAYOUT:

TRANSACTION CODE:

PROGRAM79:
REPORT

Z530PMPROG79

define abc.
&3 = &1 + &2.
&4 = &1 - &2.
end-of-definition.
data : r1 type i,r2 type i.
abc 20 10 r1 r2.
write :/ 'sum is ',r1,
/ 'difference is ',r2.
abc 60 40 r1 r2.
write :/ 'sum is ',r1,
/ 'difference is ',r2.
*
*
*
*

abc 'xyz' 'pqr' r1 r2.


write :/ 'sum is ',r1,
/ 'difference is ',r2.

PROGRAM80:
REPORT

Z530PMPROG80

parameters : p_x type i,


p_y type i.

data : lv_r1 type i,


lv_r2 type i.
call function 'Z530FM1'
exporting
i_x = p_x
i_y = p_y
importing
e_z = lv_r1
e_m = lv_r2.
write :/ lv_r1,lv_r2.

Z530FM1(SE37):

IMPORT:

EXPORT:

SOURCE CODE:
function z530fm1.
*"--------------------------------------------------------------------*"*"Local interface:
*" IMPORTING
*"
REFERENCE(I_X) TYPE I
*"
REFERENCE(I_Y) TYPE I
*" EXPORTING
*"
REFERENCE(E_Z) TYPE I
*"
REFERENCE(E_M) TYPE I
*"--------------------------------------------------------------------e_z = i_x + i_y.
e_m = i_x - i_y.

endfunction.

PROGRAM81:

INCLUDE PROGRAM:

*&--------------------------------------------------------------------*
*& Include Z81TOP
Module
poo*
*&
*
*&--------------------------------------------------------------------*
program z530pmprog81
.
type-pools vrm.
data flag type i.
data io1(3) type c.
data : lt_values type vrm_values,
*
standard table of vrm_value,
ls_values like line of lt_values.
module user_command_0100 input.
case sy-ucomm.
when 'P1'.
leave program.
when 'P2'.
if io1 = 'K1'.
flag = 2.
elseif io1 = 'K2'.

flag = 3.
endif.
endcase.
endmodule.

" USER_COMMAND_0100

module status_0100 output.


if flag eq 0.
loop at screen.
if screen-group1 = 'G1' or
screen-group2 = 'G2'.
screen-invisible = '1'.
screen-input = '0'.
modify screen.
endif.
endloop.
perform preparevalues.
flag = 1.
elseif flag eq 2.
perform customer_visible.
elseif flag eq 3.
perform material_visible.
endif.
endmodule.
" STATUS_0100

OUTPUT

form preparevalues .
clear ls_values.
ls_values-key = 'K1'.
ls_values-text = 'KNA1'.
append ls_values to lt_values.
clear ls_values.
ls_values-key = 'K2'.
ls_values-text = 'MARA'.
append ls_values to lt_values.
clear ls_values.
ls_values-key = 'K3'.
ls_values-text = 'VBAK'.
append ls_values to lt_values.
call function 'VRM_SET_VALUES'
exporting
id
= 'IO1'
values
= lt_values[].
endform.
" preparevalues
form customer_visible .
loop at screen.
if screen-group1 = 'G1'.
screen-invisible = '0'.
screen-input = '1'.
modify screen.
endif.

INPUT

if screen-group2 = 'G2'.
screen-invisible = '1'.
screen-input = '0'.
modify screen.
endif.
endloop.
endform.
" customer_visible
form material_visible .
loop at screen.
if screen-group1 = 'G1'.
screen-invisible = '1'.
screen-input = '0'.
modify screen.
endif.
if screen-group2 = 'G2'.
screen-invisible = '0'.
screen-input = '1'.
modify screen.
endif.
endloop.
endform.
" material_visible

SCREEN100:
process
module
*
process
module

before output.
status_0100.
after input.
user_command_0100.

LAYOUT:

TRANSACTION CODE:

PROGRAM82:

INCLUDE PROGRAM:

*&--------------------------------------------------------------------*
*& Include Z82TOP
Module
poo*
*&
*
*&--------------------------------------------------------------------*
program
.

z530pmprog82

controls tbstr type tabstrip.


data scrno type sy-dynnr
value '200'.
module user_command_0100 input.
case sy-ucomm.
when 'P4'.
leave program.
when 'P2'.
tbstr-activetab = 'P2'.
scrno = '300'.
when 'P1'.
tbstr-activetab = 'P1'.
scrno = '200'.
endcase.
endmodule.

SCREEN100:

" USER_COMMAND_0100

process before output.


call subscreen ref1
including sy-repid scrno.
*call subscreen ref2
*
including sy-repid scrno.
* MODULE STATUS_0100.
*
process after input.
call subscreen ref1.
*call subscreen ref2.
module user_command_0100.

LAYOUT:

INPUT

SCREEN200:

process before output.


* MODULE STATUS_0200.
*
process after input.
* MODULE USER_COMMAND_0200.

LAYOUT:

SCREEN300:

process before output.


* MODULE STATUS_0300.
*
process after input.
* MODULE USER_COMMAND_0300.

LAYOUT:

TRANSACTION CODE:

PROGRAM83:

INCLUDE PROGRAM:

*&--------------------------------------------------------------------*
*& Include Z83TOP
Module
poo*
*&
*
*&--------------------------------------------------------------------*
program
.

z530pmprog83

tables kna1.
controls tbctrl type tableview
using screen 100.
types : begin of ty_kna1,
kunnr type kna1-kunnr,
name1 type kna1-name1,
name2 type kna1-name2,
end of ty_kna1.
data : lt_kna1 type standard table of ty_kna1,
ls_kna1 type ty_kna1.
module user_command_0100 input.
case sy-ucomm.
when 'P2'.
leave program.
when 'P1'.
if kna1-land1 is not initial.
perform getcustomers.
else.
message 'Please enter country' type 'I'.
endif.
endcase.
endmodule.
" USER_COMMAND_0100 INPUT
form getcustomers .
select kunnr name1 name2
from kna1
into table lt_kna1
where land1 = kna1-land1.
if sy-subrc eq 0.
describe table lt_kna1.
tbctrl-lines = sy-tfill.
endif.
endform.
" getcustomers
*&--------------------------------------------------------------------*
*&
Module STATUS_0100 OUTPUT
*&--------------------------------------------------------------------*

*
text
*---------------------------------------------------------------------*
module status_0100 output.
kna1-kunnr = ls_kna1-kunnr.
kna1-name1 = ls_kna1-name1.
kna1-name2 = ls_kna1-name2.
endmodule.
" STATUS_0100 OUTPUT
*&--------------------------------------------------------------------*
*&
Module xyz INPUT
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
module xyz input.
call function 'POPUP_TO_INFORM'
exporting
titel
= 'Custom f1 help'
txt1
= 'KNA1 TABLE'
txt2
= 'CUSTOMER NO'.
endmodule.
" xyz INPUT
module pqr input.
call function 'POPUP_TO_INFORM'
exporting
titel = 'Custom F1 help'
txt1
= 'Button'
txt2
= 'Retrieve Customers'.
endmodule.

" pqr

INPUT

module abc input.


message 'Custom f4 help' type 'I'.
endmodule.
" abc INPUT

SCRENN100:

process before output.


loop at lt_kna1 into ls_kna1 with control tbctrl.
module status_0100.
endloop.
*
process after input.
loop.
endloop.
module user_command_0100.
process on help-request.
field kna1-land1 module xyz.
process on value-request.
field kna1-land1 module abc.

LAYOUT:

TRANSACTION CODE:

PROGRAM84:
PROGRAM85:
report

z530pmprog85

types : begin of ty_legacy,


str(100) type c,
end of ty_legacy.
data : lt_legacy type standard table of ty_legacy,
ls_legacy type ty_legacy.
types : begin of ty_kna1,
kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
end of ty_kna1.
data : lt_kna1 type standard table of ty_kna1,
ls_kna1 type ty_kna1.
types : begin of ty_bdcdata.
include structure bdcdata.
types end of ty_bdcdata.
data : lt_bdcdata type standard table of ty_bdcdata,
ls_bdcdata type ty_bdcdata.
call function 'GUI_UPLOAD'

exporting
filename
filetype
tables
data_tab

= 'c:\customer.txt'
= 'ASC'
= lt_legacy[].

if lt_legacy[] is not initial.


loop at lt_legacy into ls_legacy.
split ls_legacy-str at ','
into ls_kna1-kunnr
ls_kna1-land1
ls_kna1-name1.
append ls_kna1 to lt_kna1.
endloop.
else.
write :/ 'No data'.
endif.

loop at lt_kna1 into ls_kna1.


perform prginfo using 'Z530PROG85_CALL' '100'.
perform fldinfo using 'KNA1-KUNNR' ls_kna1-kunnr.
perform fldinfo using 'KNA1-LAND1' ls_kna1-land1.
perform fldinfo using 'KNA1-NAME1' ls_kna1-name1.
call transaction 'ZY85' using lt_bdcdata.
endloop.
form prginfo using prgname scrno.
refresh lt_bdcdata.
clear ls_bdcdata.
ls_bdcdata-program = prgname.
ls_bdcdata-dynpro = scrno.
ls_bdcdata-dynbegin = 'X'.
append ls_bdcdata to lt_bdcdata.
endform.
form fldinfo using fname fvalue.
clear ls_bdcdata.
ls_bdcdata-fnam = fname.
ls_bdcdata-fval = fvalue.
append ls_bdcdata to lt_bdcdata.
endform.

SE80:

Z530PROG85_CALL:

INCLUDE PROGRAM:
*&--------------------------------------------------------------------*
*& Include Z85CALLTOP
Module
poo*
*&
*
*&--------------------------------------------------------------------*
program z530prog85_call
.
tables kna1.
module user_command_0100 input.
case sy-ucomm.
when 'P1'.
insert kna1.
if sy-subrc eq 0.
message 'Inserted' type 'I'.
else.
message 'Not inserted' type 'I'.
endif.
when 'P2'.
leave program.
endcase.
endmodule.
" USER_COMMAND_0100

INPUT

module abc input.


case sy-ucomm.
when 'P3'.
leave program.
endcase.
endmodule.

" abc

SCREEN100:
process before output.
* MODULE STATUS_0100.
*
process after input.
module user_command_0100.
module abc at exit-command.

LAYOUT:

TRANSACTION CODE:

INPUT

PROGRAM86:
REPORT

Z530PMPROG86.

types : begin of ty_legacy,


str(100) type c,
end of ty_legacy.
data : lt_legacy type standard table of ty_legacy,
ls_legacy type ty_legacy.
types : begin of ty_kna1,
kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
end of ty_kna1.
data: lt_kna1 type standard table of ty_kna1,
ls_kna1 type ty_kna1.
types : begin of ty_bdcdata.
include structure bdcdata.
types end of ty_bdcdata.
data : lt_bdcdata type standard table of ty_bdcdata,
ls_bdcdata type ty_bdcdata.
data : dsn(40) type c
value '\\200.200.200.20\c$\customer.txt'.

open dataset dsn for input in text mode


encoding default.
if sy-subrc eq 0.
do.
read dataset dsn into ls_legacy-str.
if sy-subrc eq 0.
append ls_legacy to lt_legacy.
else.
exit.
endif.
enddo.
else.
message 'File not opened' type 'I'.
endif.
close dataset dsn.
if lt_legacy[] is not initial.
loop at lt_legacy into ls_legacy.
split ls_legacy-str at ','
into ls_kna1-kunnr
ls_kna1-land1
ls_kna1-name1.
append ls_kna1 to lt_kna1.
endloop.
endif.
* Create the session object
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT
= SY-MANDT
GROUP
= 'S11'
*
HOLDDATE
= '20111022'
KEEP
= 'X'
USER
= sy-uname.
if lt_kna1[] is not initial.
loop at lt_kna1 into ls_kna1.
perform prginfo using 'Z530PROG85_CALL' '0100'.
perform fldinfo using 'KNA1-KUNNR' ls_kna1-kunnr.
perform fldinfo using 'KNA1-LAND1' ls_kna1-land1.
perform fldinfo using 'KNA1-NAME1' ls_kna1-name1.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE
= 'ZY85'
TABLES
DYNPROTAB
= lt_bdcdata[].
endloop.
endif.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
form prginfo using prgname scrno.
refresh lt_bdcdata.
clear ls_bdcdata.

ls_bdcdata-program = prgname.
ls_bdcdata-dynpro = scrno.
ls_bdcdata-dynbegin = 'X'.
append ls_bdcdata to lt_bdcdata.
endform.
form fldinfo using fname fvalue.
clear ls_bdcdata.
ls_bdcdata-fnam = fname.
ls_bdcdata-fval = fvalue.
append ls_bdcdata to lt_bdcdata.
endform.

SE80:
Z530PROG85_CALL:

INCLUDE PROGRAM:
*&--------------------------------------------------------------------*
*& Include Z85CALLTOP
Module
poo*
*&
*
*&--------------------------------------------------------------------*
program z530prog85_call
.
tables kna1.

module user_command_0100 input.


case sy-ucomm.
when 'P1'.
insert kna1.
if sy-subrc eq 0.
message 'Inserted' type 'I'.
else.
message 'Not inserted' type 'I'.
endif.
when 'P2'.
leave program.
endcase.
endmodule.
" USER_COMMAND_0100
module abc input.
case sy-ucomm.
when 'P3'.
leave program.
endcase.
endmodule.

SCREEN100:

" abc

process before output.


* MODULE STATUS_0100.
*
process after input.
module user_command_0100.
module abc at exit-command.

LAYOUT:

INPUT

INPUT

TRANSACTION CODE:

You might also like