Module Pool Programming
Module Pool Programming
Save it.
Create it.
Save it.
Go to interface tab.
!rovide the interface name.
Save it.
Then go to the methods tab.
Then we can see the interface method name in the class method.
Then double click on the method then write the logic here.
Warning% Assume that an interval is defined from to . f you want to issue a warning at the number
9, enter (% here.
4.!ress SAVE. You would get a prompt as shown below:
5.!ress YES and assign the object to a local class.
6.Now click on "Number Ranges button on the application toolbar.
7.Click on "Change ntervals.
8.Click on "nsert nterval.
9.Enter the values as shown below:
.Click "nsert and then SAVE. The number range object is generated.
%esting the Number Range Object:
We can use the function module, N&MBER_GET_NEXT, to get the next number of any number
range object.
Following is a test program to get the next available number of the object created above:
REPJRT zsnro_test.
DATA: NUMBER TYPE I.
CALL FUNCTIJN 'NUMBER_GET_NEXT'
EXPJRTING
nr_range_nr = '01'
object = 'ZDEMJ'
IMPJRTING
NUMBER = NUMBER
EXCEPTIJNS
INTERVAL_NJT_FJUND = 1
NUMBER_RANGE_NJT_INTERN = 2
JBJECT_NJT_FJUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NJT_1 = 5
INTERVAL_JVERFLJW = 6
BUFFER_JVERFLJW = 7
JTHERS = 8
.
IF sy-subrc < 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNJ
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write :/ 'Next available number is: ', Number.
-----------------------------------------------------------------------------
-----
$chedulIng background jobs
By Rahul Tyagi
Objective: Scheduling a background job in SA! R/3. These document intents to provide steps which can
be done even by an end user to prepare a Job.
Main Steps:
.Change screen layout of stock report as per the requirement.
2.Create variant to run the stock report (MB52 via Job.
3.Access transaction code SM36 to create the Job.
4.Monitor the Job and check the spool
5.Access SA! Business Work place to check the Spool.
Step: Create Screen layout
Assumption: Go to transaction MB52 and enter the value of the !lant (let's say .
Step : Create Variant along with the layout which we have created in previous step.
!ress F4 on the layout field in initial screen and then press save.
Click on the ABA! program and mention the program and also select the variant name which was
created in initial steps.
Click on check and save
Step : Now click on the start condition button.
n this step we are giving the frequency of running the job. As already mentioned the Job needs to run
daily basis.
click on the period values button and also mark the period check box as the job has to run every day.
Click on the spool recipient button
Just press enter and save to get the message that job is in release status
Monitor and check the output of job. Access transaction code SM37.
Also mention the Job name
execute and check the spool.
click on the type
Step: Here we are with the results which is list of stock in our case
@
@
A new screen shows the output based on the selected record achieving the interactive reporting.
REPJRT ZG_JJP.
INITIALIZATIJN.
TYPES : BEGIN JF TY_MARD,
MATNR TYPE MARD-MATNR,
WERKS TYPE MARD-WERKS,
LGJRT TYPE MARD-LGJRT,
END JF TY_MARD,
BEGIN JF TY_MARA,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
MTART TYPE MARA-MTART,
MATKL TYPE MARA-MATKL,
END JF TY_MARA,
BEGIN JF TY_MAKT,
MATNR TYPE MAKT-MATNR,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END JF TY_MAKT,
BEGIN JF TY_FINAL,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
MTART TYPE MARA-MTART,
MATKL TYPE MARA-MATKL,
WERKS TYPE MARD-WERKS,
LGJRT TYPE MARD-LGJRT,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END JF TY_FINAL.
***** THE INITIALIZATION PART CREATING WORKAREA AND INTERNAL TABLE*****
DATA : W_MARD TYPE TY_MARD,
I_MARD TYPE TABLE JF TY_MARD,
W_MARA TYPE TY_MARA,
I_MARA TYPE TABLE JF TY_MARA,
W_MAKT TYPE TY_MAKT,
I_MAKT TYPE TABLE JF TY_MAKT,
W_FINAL TYPE TY_FINAL,
I_FINAL TYPE TABLE JF TY_FINAL.
**************************START-OF-SELECTION.**************************
START-JF-SELECTIJN.
*************************GET INPUT FROM USER***************************
PARAMETER : PLANT TYPE MARD-WERKS,
STLJC TYPE MARD-LGJRT.
****SELECT DATA FROM DATABASE INTO INTERNAL TABLES***********************
****SELECT FROM MARD THE REQUIRED FIELDS FOR THE GIVEN INPUT*************
SELECT MATNR
WERKS
LGJRT
FRJM MARD
INTJ TABLE I_MARD
WHERE WERKS = PLANT AND LGJRT = STLJC.
*****CHECK IF RECORDS ARE FETCHED IF NO EXIT OUT OF THE PROGRAM********
IF SY-SUBRC < 0.
WRITE 'NJ RECJRDS'.
EXIT.
ELSE.
***IF RECORDS ARE FETCHED FROM FRIST TABLE*****************************
****FETCH RELATED RECORDS FROM NEXT TABLE******************************
SELECT MATNR
ERSDA
ERNAM
MTART
MATKL
FRJM MARA
INTJ TABLE I_MARA
FJR ALL ENTRIES IN I_MARD
WHERE MATNR = I_MARD-MATNR.
IF SY-SUBRC < 0.
WRITE 'NJ MASTER DATA'.
STJP.
ELSE.
SELECT MATNR SPRAS MAKTX
FRJM MAKT
INTJ TABLE I_MAKT
FJR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR AND SPRAS = 'E'.
ENDIF.
ENDIF.
*****READ FROM INTERNAL TABLE FOR OUTPUT ******************************
LJJP AT I_MARA INTJ W_MARA.
AT FIRST.
WRITE : SY-ULINE(100),
/1 SY-VLINE,
25 'EXAMPLE INTERACTIVE REPJRT',
100 SY-VLINE,
/ SY-ULINE(100), /1 SY-VLINE,
2 'MATERIAL NUMBER' ,
20 SY-VLINE,
22 'CREATIJN DATE',
40 SY-VLINE,
42 'USER NAME',
60 SY-VLINE,
62 'MATERIAL TYPE',
80 SY-VLINE,
82 'MATERIAL GRJUP',
100 SY-VLINE,
/ SY-ULINE(100).
ENDAT.
JN CHANGE JF W_MARA-MATNR.
READ TABLE I_MARD INTJ W_MARD WITH KEY MATNR = W_MARA-MATNR.
ENDJN.
WRITE :/1 SY-VLINE,
2 W_MARA-MATNR ,
20 SY-VLINE,
22 W_MARA-ERSDA,
40 SY-VLINE,
42 W_MARA-ERNAM,
60 SY-VLINE,
62 W_MARA-MTART,
80 SY-VLINE,
82 W_MARA-MATKL,
100 SY-VLINE.
HIDE W_MARA-MATNR.
CLEAR W_MARA-MATNR.
WRITE: / SY-ULINE(100).
ENDLJJP.
END-JF-SELECTIJN.
*************************************END-OF-SELECTION.
****MOVING VALUES IN TO FINAL INTERNAL TABLE **************************
LJJP AT I_MARA INTJ W_MARA.
JN CHANGE JF W_MARA-MATNR.
READ TABLE I_MAKT INTJ W_MAKT WITH KEY MATNR = W_MARA-MATNR.
READ TABLE I_MARD INTJ W_MARD WITH KEY MATNR = W_MARA-MATNR.
ENDJN.
W_FINAL-MATNR = W_MARA-MATNR.
W_FINAL-ERSDA = W_MARA-ERSDA.
W_FINAL-ERNAM = W_MARA-ERNAM.
W_FINAL-MTART = W_MARA-MTART.
W_FINAL-MATKL = W_MARA-MATKL.
W_FINAL-WERKS = W_MARD-WERKS.
W_FINAL-LGJRT = W_MARD-LGJRT.
W_FINAL-SPRAS = W_MAKT-SPRAS.
W_FINAL-MAKTX = W_MAKT-MAKTX.
APPEND W_FINAL TJ I_FINAL.
ENDLJJP.
********AT LINE-SELECTION EVENT TRIGERING INTERACTIVE REPORTING.*******
AT LINE-SELECTIJN.
CASE SY-LSIND.
WHEN 1.
**DISPLAY OUTPUT IN NEW SCREEN AT LINE SELECTION BY USER MOUSE CLICK **
WRITE: / W_MARA-MATNR CJLJR 2.
READ TABLE I_FINAL INTJ W_FINAL WITH KEY MATNR = W_MARA-MATNR SPRAS = 'EN'.
ULINE 1(200).
WRITE : /1 SY-VLINE,
75 'EXAMPLE INTERACTIVE REPJRT',
200 SY-VLINE,
SY-ULINE(200),
/1 SY-VLINE,
2 'MATERIAL NUMBER' ,
20 SY-VLINE,
22 'CREATIJN DATE',
40 SY-VLINE,
42 'USER NAME',
60 SY-VLINE,
62 'MATERIAL TYPE',
80 SY-VLINE,
82 'MATERIAL GRJUP',
100 SY-VLINE,
102 'PLANT NUMBER',
120 SY-VLINE,
122 'STJRAG LJCATIJN',
140 SY-VLINE,
142 'LANGUAGE',
160 SY-VLINE,
162 'DESCRIPTIJN',
200 SY-VLINE,
/ SY-ULINE(200).
WRITE :/1 SY-VLINE,
2 W_FINAL-MATNR ,
20 SY-VLINE,
22 W_FINAL-ERSDA,
40 SY-VLINE,
42 W_FINAL-ERNAM,
60 SY-VLINE,
62 W_FINAL-MTART,
80 SY-VLINE,
82 W_FINAL-MATKL,
100 SY-VLINE,
102 W_FINAL-WERKS,
120 SY-VLINE,
122 W_FINAL-LGJRT,
140 SY-VLINE,
142 W_FINAL-SPRAS,
160 SY-VLINE,
162 W_FINAL-MAKTX,
200 SY-VLINE,
/ SY-ULINE(200).
CLEAR W_MARA-MATNR.
ENDCASE.
--------------------------------------------------------------------------
Create namIc $electIon $creen
By Marcos Munhos, C!M Braxis
escription
This is a demo application to make a dynamic screen in a report.
This change the parameters according a radio button choice:
st
moment - Click on the radio button ocaI
n the block "Enter Parameters", we'll have 2 parameters.
The parameter in the block "Path" is named as ocaI Path and the match code will lead you to a
File Open Dialog.
2
nd
moment - Click in the radio button Server
n the Enter Parameters, we'll have just parameter.
The parameter in the block "Path" is now named as Server Path and the field will be disabled.
Step b Step Approach
Create a new report.
n the SEEC%ION SCREEN put all the fields, blocks and parameters necessary, notice that in the radio
button have the addiction USER-COMMAN to enable the event A% SEEC%ION-SCREEN OU%PU%.
Look that in the Iock 2 we have the both parameters p_IocaI and p_sever, at the same time.
At this time the report is something like this:
Event A% SEEC%ION-SCREEN OU%PU%
n this event you can manipulate all the objects that appears in the screen using OOP A% SCREEN
changing the value of the structure screen the way you want . See below:
For this create a function module, write the logic according to the requirement and place the function
module in marked location.
Function module structure definition: Create a parameters in changing and Tables tabs as follows.
Code:
DATA : WA_TEMP LIKE RECJRD_TAB,
IT_TEMP LIKE RECJRD_TAB JCCURS 0.
IF CALLCJNTRJL-STEP = 'DISP'.
IF SY-UNAME = 'XXXXXX'.
LJJP AT RECJRD_TAB INTJ WA_TEMP WHERE STRING+3(4) = 'FERT'.
APPEND WA_TEMP TJ IT_TEMP.
CLEAR: WA_TEMP.
ENDLJJP.
CLEAR: RECJRD_TAB,.
RECJRD_TAB, = IT_TEMP,.
CLEAR: IT_TEMP,.
ELSEIF SY-UNAME = 'YYYYYY'.
LJJP AT RECJRD_TAB INTJ WA_TEMP WHERE STRING+3(4) = 'RJH'.
APPEND WA_TEMP TJ IT_TEMP.
CLEAR: WA_TEMP.
ENDLJJP.
CLEAR: RECJRD_TAB,.
RECJRD_TAB, = IT_TEMP,.
CLEAR: IT_TEMP,.
ENDIF.
ENDIF.
Save and activate it.
Then place the Function module above location in SE.
Testing:
Go to any Transaction which has material number.
Ex: ME2N. !ress F4 on Material Field.
User1 ResuIt
User2 ResuIt