Simple report program
Hi everyone,
I have two fields namely PERNR and PERID in the table xxxxxx.
PERNR is a unique key field where as PERID is not a unique key.
In the table i have the value as follows
PERNR PERID
65000392 717734001
65000393 717734001
65000394 717734000
65000395 717734002
65000396 717734003
65000397 717734003
What operation can be done so that the output I should get is
The duplicate records are:
PERNR PERID
65000392 717734001
65000393 717734001
65000396 717734003
65000397 717734003
Kindly help in making this output.Thanx in advance.
Hi Sateesh,
data:
itab_dup like table of itab,
itab_result like table of itab,
itab_final_result like table of itab,
fs_dup like line of itab_dup.
itab_dup[] = itab[].
loop at itab into fs_itab..
count = 0.
loop at itab_dup into fs_dup where perid eq fs_itab-perid
count = count + 1.
append fs_dup to itab_result.
endloop.
if count > 1.
append lines of itab_result into itab_final_result.
else.
refresh itab_result.
endif.
endloop.
loop at itab_final_result into fs_itab_final_result.
write fs_itab_final_result.
endloop.
Similar Messages
-
Remote enabled Function module for a simple report program
Hi Experts ,
I have to convert a Simple list report program to a remote enabled function module, so that it can be used from the online applications.
One option that comes to my mind is to create some import parameters for all the selection screen fields and then the result will be fetched in the export tables in function module. and call that report program using call transaction or submit program.
I Dont know whether this is a best solution or not, can you please help me with your suggestions?
Regards,
Ashish ShahHi,
You can use the SUBMIT statment in the Function module , then in the report program you need to EXPORT the Result to the list then use the IMPORT option in the function moduel then pass the data to the TABLE parameters so that the data will be avilable in the table parameters
Regards
Sudheer -
DOWNLOADING A REPORT PROGRAM CODE IN TO TEXT FILE
I HAVE ONE SIMPLE REPORT PROGRAM SAY,
*& Report ZTEST25
REPORT ZTEST25.
DATA : A(8) TYPE C.
A = 'ANDHRA'.
WRITE A.
THE ABOVE MENTIONED REPORT PROGRAM SHOULD BE DOWNLOADED TO A TEXT FILE USING ANOTHER REPORT PROGRAM BY USING PARAMETER.
THE OUTPUT IN THE FLAT FILE SHOULD BE:
REPORT ZTEST25.
DATA : A(8) TYPE C.
A = 'ANDHRA'.
WRITE A.here is complete code for that
report z11dpk_assign1
no standard page heading
message-id z11dpk
line-size 200 "page width
line-count 65(0). "page length.
T A B L E S D E C L A R A T I O N *
tables: trdir, " System Table TRDIR
trdirt. " Title texts for programs in
D A T A D E C L A R A T I O N *
Types
Structure declaration for system table
types: begin of struct_sys,
name(40) type c, " ABAP program name
clas(4) type c, " Program class
subc(1) type c, " Program type
cnam(12) type c, " Author
cdat type dats, " Created on
rstat(1) type c, " status
text type repti, " Report title
c_box(1) type c, " for check box
end of struct_sys.
Structure for internal table for report data
types: begin of struct_report,
line(500),
end of struct_report.
C O N S T A N T S D E C L A R A T I O N S
data : c_name(50) type c, " Program Name
c_filename like ibipparms-path, " File name
c_filename1 type string, " File name
c_ext(5) value '.TXT', " File extension
c_textline(150) type c, " downloading status
c_count type c, " no of pgm downlded
c_count_text(100) type c. " Text pgm downlded
The CONSTANTS statement defines global and local constants.
By using constants, you can read statically declared data objects,
constants: c_const(8) value 'UNTITLED'.
I N T E R N A L T A B L E D E C L A R A T I O N
data: it_sys type standard table of struct_sys, " Itab for sys data
it_report type standard table of struct_report with
non-unique default key initial size 1000. " Itab for rep data
W O R K A R E D E C L A R A T I O N S
data: wa_sys type struct_sys, " Work area for sys data
wa_report type struct_report. " Work area for report data
I N I T I A L I Z T I O N
initialization.
clear : wa_sys.
refresh: it_sys,
it_report.
c_count = 0.
S E L E C T I O N - S C R E E N
selection-screen : begin of block blk3 with frame title text-015.
selection-screen : begin of block blk1 with frame title text-001.
select-options : s_name for trdir-name. " Program name
selection-screen : end of block blk1.
selection-screen : begin of block blk2 with frame title text-002.
parameters : p_file type rlgrap-filename. " Path for loc folder
selection-screen : end of block blk2.
selection-screen : end of block blk3.
A T S E L E C T I O N - S C R E E N
*The possible entries pushbutton for F4 appears beside the appropriate
*fld (p_file) When the user activates this pushbutton or presses F4 for
*the fld, the event is executed You can thus implement a self-programmed
*possible entries routine for the input/output fields of the selection
*screen
at selection-screen on value-request for p_file.
Value of Local file for upload/download is obtained by using this FM
call function 'F4_FILENAME'
importing
file_name = p_file.
S T A R T - O F - S E L E C T I O N
start-of-selection.
CONCATENATE p_name '%' INTO z_name.
select name
clas
subc
cnam
cdat
rstat into table it_sys
from trdir
*Sorts the selected records in ascending order by the specified column
*references f1 ... fn (name)
where name in s_name order by name.
WHERE name LIKE 'Z11%'.
if sy-subrc = 0.
sort it_sys by name.
clear wa_sys.
loop at it_sys into wa_sys.
select single text
into wa_sys-text
from trdirt
where name = wa_sys-name and
sprsl = sy-langu.
modify it_sys from wa_sys index sy-tabix.
clear wa_sys.
endloop.
endif.
set pf-status 'MENU_ASSIGN1'.
uline.
write:/ sy-vline ,
8 sy-vline, text-009 color 4, " Name of the Program
55 sy-vline, text-003 color 4, " Class
62 sy-vline, text-004 color 4, " Type
68 sy-vline, text-005 color 4, " Created By
80 sy-vline, text-006 color 4, " Created On
92 sy-vline, text-007 color 4, " Status
100 sy-vline, text-008 color 4, " Program text
180 sy-vline.
clear wa_sys.
loop at it_sys into wa_sys.
uline.
write:/ sy-vline,
5 wa_sys-c_box as checkbox,
8 sy-vline, wa_sys-name,
55 sy-vline, wa_sys-clas,
62 sy-vline, wa_sys-subc,
68 sy-vline, wa_sys-cnam,
80 sy-vline, wa_sys-cdat,
92 sy-vline, wa_sys-rstat,
100 sy-vline, wa_sys-text,
180 sy-vline.
endloop.
at user-command.
case sy-ucomm.
when 'BACK'.
leave screen.
when 'EXIT'.
leave program.
when 'DOWN'.
clear wa_sys.
do.
clear wa_sys.
read line sy-index field value wa_sys-c_box wa_sys-name.
if sy-subrc <> 0.
exit.
endif.
*if check box is selected.....
if wa_sys-c_box = 'X'.
clear c_textline.
*Assigns the contents of the source field to the target field as a new
*value
write text-010 to c_textline. " Downloading
write wa_sys-name to c_textline+12.
write text-011 to c_textline+53. "to
write c_filename1 to c_textline+56. " file name
FM returns the Text to be displayed on screen
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = c_textline.
c_count = c_count + 1.
Reads the program prog from the database into the internal table itab.
The line length of table itab should be at least 72 characters
read report wa_sys-name into it_report.
if sy-subrc <> 0.
exit.
endif.
*p_file contains the character string untitiled
This comparison is not case sensitive
if p_file cs c_const. " Untitled
the string ''(space) replaces the untitled occurrence of the search
ignore case is used as this search is case sensitive
replace c_const in p_file with '' ignoring case.
endif.
Places the fields f1 to fn (n >= 2) after g (target field).
concatenate p_file wa_sys-name c_ext into c_filename1.
*Data transmission of an internal table from the server to a file on the
PC is done by this FM.
call function 'GUI_DOWNLOAD'
exporting
filename = c_filename1
filetype = 'ASC'
tables
data_tab = it_report.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
enddo.
clear c_count_text.
write c_count to c_count_text+1.
write text-030 to c_count_text+4.
Nos Of Pgms downlded successfully
message i205 with c_count_text.
endcase.
T O P - O F - P A G E
top-of-page.
uline.
write:/ sy-vline,
10 text-020 color 2, " Fujitsu India Limited
70 text-021 color 2. " List of ABAP Programs
write:/ sy-vline,
10 text-022 color 3, sy-datum color 3, " Date
70 text-023 color 3, sy-pagno color 3. " Page No
plz reward if helpful
vivek -
Call Normal Report program in workflow?
Hi all,
My requirement is that i want to call a simple report program in workflow?
eg-when i entered material num ,the data related to that material is displayed from MARA table.
when i execute my workitem ,i want that output of report to be displayed.
i have created a z object in that i called one z method ,in that method i have written,
'SUBMIT PrgName AND RETURN.
but it is not working.
Thanks and Regards,
Arpita.Hi Arpita,
I am not sure if a report program can be called from workflow. But would it be possible for you to convery your report program into a BO method? A BO method can be easily called from a workflow.
Please clarify if you have a different requirement.
Regards,
Saumya -
What is difference between report programming and dialog programming?
hi,
what is difference between report programming and dialog programming? plz provide some example code
byeABAP programming
Basically reports are used to read database and represent the results in lists.
Reports are collections of processing blocks that the system calls depending on events.
We can use reports to evaluate data from database tables.
Reports are stand alone programs and controlled by events.
A report itself never creates events
steps in report:
Processing the selection screen
Reading the database
Evaluating the data and creating lists
Outputting a list.
1st u write simple logics, after that u can enhance the code as step by step.
http://venus.imp.mx/hilario/Libros/TeachYrslfAbap4/index.htm
http://help.sap.com/saphelp_47x200/helpdata/en/d1/802cfc454211d189710000e8322d00/frameset.htm
http://www.sapdev.co.uk/reporting/reportinghome.htm
Dialog Programming
Structure of a Dialog Program
A dialog program consists of the following basic components:
Screens (dynpros)
Each dialog in an SAP system is controlled by dynpros. A dynpro (DYnamic PROgram) consists of a screen and its flow logic and controls exactly one dialog step. The flow logic determines which processing takes place before displaying the screen (PBO-Process Before Output) and after receiving the entries the user made on the screen (PAI-Process After Input).
The screen layout fixed in the Screen Painter determines the positions of input/output fields, text fields, and graphical elements such as radio buttons and checkboxes. In addition, the Menu Painter allows to store menus, icons, pushbuttons, and function keys in one or more GUI statuses. Dynpros and GUI statuses refer to the ABAP/4 program that control the sequence of the dynpros and GUI statuses at runtime.
ABAP/4 module pool
Each dynpro refers to exactly one ABAP/4 dialog program. Such a dialog program is also called a module pool, since it consists of interactive modules. The flow logic of a dynpro contains calls of modules from the corresponding module pool. Interactive modules called at the PBO event are used to prepare the screen template in accordance to the context, for example by setting field contents or by suppressing fields from the display that are not needed. Interactive modules called at the PAI event are used to check the user input and to trigger appropriate dialog steps, such as the update task.
All dynpros to be called from within one transaction refer to a common module pool. The dynpros of a module pool are numbered. By default, the system stores for each dynpro the dynpro to be displayed next. This dynpro sequence or chain can be linear as well as cyclic. From within a dynpro chain, you can even call another dynpro chain and, after processing it, return to the original chain.
Check this link for basics.
http://sap.mis.cmich.edu/sap-abap/abap09/index.htm
Check this link for Dialog Programming/Table Control
http://www.planetsap.com/Tips_and_Tricks.htm#dialog
Check this SAP Help for Dialog Program doc.
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm
Check this SAP Help link for Subscreens.
http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbabfe35c111d1829f0000e829fbfe/content.htm
Check this link for subscreen demo program.
http://abapcode.blogspot.com/2007/05/demo-program-to-create-subscreen-in.html
Also check this link too.
http://abapcode.blogspot.com/2007/06/dialog-programming-faq.html
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/frameset.htm
http://sap.mis.cmich.edu/sap-abap/abap09/sld004.htm
http://help.sap.com/saphelp_nw04/helpdata/en/52/670ba2439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/52/670c17439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/52/670c17439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9ccf35c111d1829f0000e829fbfe/frameset.htm
http://abapprogramming.blogspot.com/ -
Few questions on Report programming
Hi guys,
I have few questions on report programming.
1. What is the purpose of the statement REPORT zxxx. Even if i gave a name other than my report name i don't find any difference in syntax check/Functionality.
2. What is the purpose of list headings in report program? This option will come along with the text elements and selection texts.
3. What is the purpose of logical data base. Even if it is efficient why don't we use it frequently in our reports? Is there any limitations?
All usefull answers will be rewarded as usuall:-)
Thanks,
Vinod.1. As u told that you dint get any syntax errors even after changing the Report Name,there are chances of getting Runtime errors.
2. The usage of List Headings is when you create a list in a program, you can also create your own list and column headings.
Refer this link for further info.
http://help.sap.com/saphelp_nw70/helpdata/en/e3/960a05eb0711d194d100a0c94260a5/content.htm
3. The Limitation of LDB is the usage of GET statements which act similar to SELECT - ENDSELECT And also if you dont choose the proper LDB,a single LDB may contain data retrieval from so many tables ,that it would make the entire process very slow and it is very hard to find LDBs for other modules than HR.
Only in HR module the data is organized in such a way thatusing LDBs would be much simpler.
Reward points if useful. -
About call a webdynpro program in R/3 report program.
hi,experts
i am searching a report program which was written by my colleague who have left my project.
there is one button displayed on the ALV tool bar of this report program.when i push this button,a message are sent to protal and displayed in tasks,then i log into portal,double click the message,a webdynpro program will be called and used to further process.
i really want to know how i can decide to use which webdynpro program to be call and used. for example,now the R/3 program use the webdynpro program named AAA, i copy BBB from AAA,and want to replace AAA by BBB in this program, how?
i don't know how to meet this simple requirement such as upwards and confused about it. hope anyone can show me some information.
thanks in advance.It is not that simple :).
Actually there is a workflow involvedi n this. On clicking the alv button a workflow gets triggered and the task appears in the SAP Inbox which anyway displayed in the UWL of the Portal.
just try changing the SWFVISU transaction entry for that particular task and change the applicaiton name to your new application name and re-register the system in the UWL Admin Pagem, i hope it works.
If you did not find any entry in SWFVISU, the developer might have exported the XML in UWL Administration page in the portal down load it identify the old applicaiton name nad replace it with your new application name and upload the XML
[Helpful link|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d0731bbc-810b-2a10-7fb8-900f16fd3c7d]
Abhi -
Hi,
I would like to know if its possible to create a report
program from a function module instead of going to SE38?
I want to write a function module which takes Report Pgm
Name and the Source Code as its input parameters and
create the report pgm.
Is any function available in SAP for creating a report
program? If so wat is it?
Ps: I do not want to generate a sub-routine pool.
Thanks in advance.Hi anandaraja,
1. Simple.
2. we have to use the command
INSERT REPORT 'ZPROG' from itab.
3. just copy paste in new program.
It will create a new program
'ZAM_TEMP05'.
(this new program will just print amit)
4. U can use this code in the code of your FM.
(by passing programname, and source in the form
on internal table thru TABLES parameter)
5.
REPORT ABC.
DATA : BEGIN OF ITAB OCCURS 0,
F(72) TYPE C,
END OF ITAB.
ITAB-F = 'REPORT ABC.'.
APPEND ITAB.
ITAB-F = 'WRITE '' AMIT '' .'.
APPEND ITAB.
INSERT REPORT 'ZAM_TEMP05' FROM ITAB.
regards,
amit m. -
ALV Report program linking 5 db tables.
What should be the general approach to generate a simple ALV program that links 5 database tables, where the selection criteria is date field?
Edited by: Matt on Dec 4, 2008 11:38 AM - Removed all capsSAP Query is a bit of an abomination -- complicated to use correctly and definitely difficult to maintain.
If you need to get stuff from 5 different databases in one report it might be better from a Systems Performance perspective to create a "Z_object" containing the data you want and then simply run your ABAP ALV against your "Z_Object".
Depending on the frequency / content of your report you could run say a batch job every evening to update your "Z_Object".
The other possibility would be to run your query on a BW/BI system if the volume of data is quite large -- however if you don't have BW then OK this is not a possible solution.
My preference would be to go for the "Z-Object".
I also have to wonder at how the original application was designed if you really do need to collect data from 5 different data bases --perhaps you should re-design the original application.
Cheers
jimbo. -
Hi all,
i am a beginner in ABAP,plz explain me clearly about the events in report programming.
thanks,
jetti.List Events in an ABAP Program
After a user interaction on a list, the ABAP runtime environment checks whether it should process the function code itself (for example, %EX or %PC), or whether it should trigger the relevant event. Unlike normal screens, in which the PAI event is triggered, the runtime environment triggers three special events when list events occur. You can use the corresponding event blocks in your ABAP program to react to the user action. From within the program, you can use the SY-UCOMM system field to access the function code. There is no OK_CODE field that is filled.
Event Blocks for Function Codes PF<nn> (Obsolete)
When the user chooses a function code PF<nn> (<nn> can be between 01 and 24), the system always triggers the AT PF<nn> event. In the standard list status, the function keys F<nn> that are not reserved for predefined system functions all have the function code PF<nn> as long as a corresponding event block is defined in the program.
AT PF<nn>.
<statements>.
These event blocks are executed when the user chooses the corresponding function key. The position of the cursor in the list is irrelevant.
If you use these event blocks at all, it should only be for temporary test versions. In production programs, you should only use AT USER-COMMAND with a dialog status of your own to assign function codes to function keys. When you use your own interfaces, the system displays a function text explaining what the function does. This does not happen when you use AT PF<nn> event blocks.
Event Block for Function Code PICK
When the user triggers the function code PICK, AT LINE-SELECTION is always triggered if the cursor is positioned on a list line. The function code PICK is, by default, always linked with function key F2 and hence with the mouse double-click. Consequently, if you have a simple program that does not react to any further user actions, you only need to write this event block.
AT LINE-SELECTION.
<statements>.
As described in the section Dialog Status for Lists, the function code PICK is always added to the standard list status when you have an AT LINE-SELECTION event in your program.
If you assign PICK to other function keys or menu entries, AT LINE-SELECTION is also triggered when the user chooses then. You should avoid this for the sake of the semantics.
Conversely, if you have a more extensive program that does not react to line selection, you should not use the function code PICK. Instead you should assign a different function code to F2 , to ensure that as many events as possible trigger the AT USER-COMMAND event.
Event Block for User-Defined Function Codes
If the user chooses a function code during list processing that is neither processed by the system, or PICK or PF<nn>, the system triggers the event AT USER-COMMAND. For this event, you must define your own GUI status for a list. To react to your own function codes in a program, you must define the following event block:
AT USER-COMMAND.
<statements>.
In this event block, you can use an IF or CASE structure to tell the function codes apart. They are available in the system field SY-UCOMM. There are further system fields that are filled in list events, such as SY-LSIND and SY-PFKEY, that allow you to make further case distinctions.
Triggering a List Event from the Program
You can trigger a list event from the program as follows:
SET USER-COMMAND <fc>.
This statement takes effect after the current list is completed. Before the list is displayed, the event assigned to function code <fc> is triggered, regardless of the dialog status you are using.
The effect is the same as when the user chooses the function. In other words, predefined list function codes are trapped and processed by the runtime environment, the function codes PICK and PF<nn> trigger the AT LINE-SELECTION and AT PF<nn> events, and user-defined function codes trigger the AT USER-COMMAND event block.
Function code PICK triggers an event only if the cursor is located on a list line.
Using this statement in conjunction with the function codes reserved for system functions, you can call the system functions from the program. For example, you can use SET USER-COMMAND '%SC' to call the Find dialog box directly, or to position the list correctly before it is displayed.
If you use several SET USER-COMMAND statements while creating a list, the system executes only the last one.
Examples
Example for AT LINE-SELECTION.
REPORT demo_list_at_line_selection.
START-OF-SELECTION.
WRITE 'Basic List'.
AT LINE-SELECTION.
WRITE: 'Secondary List by Line-Selection',
/ 'SY-UCOMM =', sy-ucomm.
When you run the program, the basic list appears with the standard list status. The detail list shows that SY-UCOMM has the value PICK.
Example for AT PF<nn>.
REPORT demo_list_at_pf.
START-OF-SELECTION.
WRITE 'Basic List, Press PF5, PF6, PF7, or PF8'.
AT pf5.
PERFORM out.
AT pf6.
PERFORM out.
AT pf7.
PERFORM out.
AT pf8.
PERFORM out.
FORM out.
WRITE: 'Secondary List by PF-Key Selection',
/ 'SY-LSIND =', sy-lsind,
/ 'SY-UCOMM =', sy-ucomm.
ENDFORM.
After executing the program, the system displays the basic list. The user can press the function keys F5 , F6 , F7 , and F8 to create secondary lists. If, for example, the 14th key the user presses is F6 , the output on the displayed secondary list looks as follows:
Secondary List by PF-Key Selection
SY-LSIND = 14
SY-UCOMM = PF06
Example for AT USER-COMMAND.
REPORT demo_list_at_user_command NO STANDARD PAGE HEADING.
START-OF-SELECTION.
WRITE: 'Basic List',
/ 'SY-LSIND:', sy-lsind.
TOP-OF-PAGE.
WRITE 'Top-of-Page'.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.
CASE sy-pfkey.
WHEN 'TEST'.
WRITE 'Self-defined GUI for Function Codes'.
ULINE.
ENDCASE.
AT LINE-SELECTION.
SET PF-STATUS 'TEST' EXCLUDING 'PICK'.
PERFORM out.
sy-lsind = sy-lsind - 1.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'FC1'.
PERFORM out.
WRITE / 'Button FUN 1 was pressed'.
WHEN 'FC2'.
PERFORM out.
WRITE / 'Button FUN 2 was pressed'.
WHEN 'FC3'.
PERFORM out.
WRITE / 'Button FUN 3 was pressed'.
WHEN 'FC4'.
PERFORM out.
WRITE / 'Button FUN 4 was pressed'.
WHEN 'FC5'.
PERFORM out.
WRITE / 'Button FUN 5 was pressed'.
ENDCASE.
sy-lsind = sy-lsind - 1.
FORM out.
WRITE: 'Secondary List',
/ 'SY-LSIND:', sy-lsind,
/ 'SY-PFKEY:', sy-pfkey.
ENDFORM.
When you run the program, the system displays the following basic list with a the page header defined in the program:
You can trigger the AT LINE-SELECTION event by double-clicking a line. The system sets the status TEST and deactivates the function code PICK. The status TEST contains function codes FC1 to FC5. These are assigned to pushbuttons in the application toolbar. The page header of the detail list depends on the status.
Here, double-clicking a line no longer triggers an event. However, there is now an application toolbar containing five user-defined pushbuttons. You can use these to trigger the AT USER-COMMAND event. The CASE statement contains a different reaction for each pushbutton.
For each interactive event, the system decreases the SY-LSIND system field by one, thus canceling out the automatic increase. All detail lists now have the same level as the basic list and thus overwrite it. While the detail list is being created, SY-LSIND still has the value 1.
Example for SET USER-COMMAND.
REPORT demo_list_set_user_command NO STANDARD PAGE HEADING.
START-OF-SELECTION.
SET USER-COMMAND 'MYCO'.
WRITE 'Basic List'.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'MYCO'.
WRITE 'Secondary List from USER-COMMAND,'.
WRITE: 'SY-LSIND', sy-lsind.
SET USER-COMMAND 'PF05'.
ENDCASE.
AT pf05.
WRITE 'Secondary List from PF05,'.
WRITE: 'SY-LSIND', sy-lsind.
SET CURSOR LINE 1.
SET USER-COMMAND 'PICK'.
AT LINE-SELECTION.
WRITE 'Secondary List from LINE-SELECTION,'.
WRITE: 'SY-LSIND', sy-lsind.
SET USER-COMMAND '%SC'.
This program creates one basic list and three detail lists. When the program starts, the third detail list is displayed immediately, along with a dialog box for searching in the list. The dialog box is displayed by setting the predefined function code %SC. To view the other lists, the user chooses Back.
Note that in the event AT PF05, the SET CURSOR statement is used to position the cursor on a list line in order to support the function code PICK. -
Simple transformation program debugging
hi ,
can any boby guide me how can we debug a simple transformation program which is used for xml to abap conversion .Hi,
have a look on this.
REPORT YMS_XMLTOSAP.
TYPE-POOLS: IXML.
TYPES: BEGIN OF T_XML_LINE,
DATA(256) TYPE X,
END OF T_XML_LINE.
DATA: L_IXML TYPE REF TO IF_IXML,
L_STREAMFACTORY TYPE REF TO IF_IXML_STREAM_FACTORY,
L_PARSER TYPE REF TO IF_IXML_PARSER,
L_ISTREAM TYPE REF TO IF_IXML_ISTREAM,
L_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
L_NODE TYPE REF TO IF_IXML_NODE,
L_XMLDATA TYPE STRING.
DATA: L_ELEM TYPE REF TO IF_IXML_ELEMENT,
L_ROOT_NODE TYPE REF TO IF_IXML_NODE,
L_NEXT_NODE TYPE REF TO IF_IXML_NODE,
L_NAME TYPE STRING,
L_ITERATOR TYPE REF TO IF_IXML_NODE_ITERATOR.
DATA: L_XML_TABLE TYPE TABLE OF T_XML_LINE,
L_XML_LINE TYPE T_XML_LINE,
L_XML_TABLE_SIZE TYPE I.
DATA: L_FILENAME TYPE STRING.
PARAMETERS: PA_FILE TYPE CHAR1024 DEFAULT 'c:\temp\orders_dtd.xml'.
* Validation of XML file: Only DTD included in xml document is supported
PARAMETERS: PA_VAL TYPE CHAR1 AS CHECKBOX.
START-OF-SELECTION.
* Creating the main iXML factory
L_IXML = CL_IXML=>CREATE( ).
* Creating a stream factory
L_STREAMFACTORY = L_IXML->CREATE_STREAM_FACTORY( ).
PERFORM GET_XML_TABLE CHANGING L_XML_TABLE_SIZE L_XML_TABLE.
* wrap the table containing the file into a stream
L_ISTREAM = L_STREAMFACTORY->CREATE_ISTREAM_ITABLE( TABLE = L_XML_TABLE
SIZE = L_XML_TABLE_SIZE ).
* Creating a document
L_DOCUMENT = L_IXML->CREATE_DOCUMENT( ).
* Create a Parser
L_PARSER = L_IXML->CREATE_PARSER( STREAM_FACTORY = L_STREAMFACTORY
ISTREAM = L_ISTREAM
DOCUMENT = L_DOCUMENT ).
* Validate a document
IF PA_VAL EQ 'X'.
L_PARSER->SET_VALIDATING( MODE = IF_IXML_PARSER=>CO_VALIDATE ).
ENDIF.
* Parse the stream
IF L_PARSER->PARSE( ) NE 0.
IF L_PARSER->NUM_ERRORS( ) NE 0.
DATA: PARSEERROR TYPE REF TO IF_IXML_PARSE_ERROR,
STR TYPE STRING,
I TYPE I,
COUNT TYPE I,
INDEX TYPE I.
COUNT = L_PARSER->NUM_ERRORS( ).
WRITE: COUNT, ' parse errors have occured:'.
INDEX = 0.
WHILE INDEX < COUNT.
PARSEERROR = L_PARSER->GET_ERROR( INDEX = INDEX ).
I = PARSEERROR->GET_LINE( ).
WRITE: 'line: ', I.
I = PARSEERROR->GET_COLUMN( ).
WRITE: 'column: ', I.
STR = PARSEERROR->GET_REASON( ).
WRITE: STR.
INDEX = INDEX + 1.
ENDWHILE.
ENDIF.
ENDIF.
* Process the document
IF L_PARSER->IS_DOM_GENERATING( ) EQ 'X'.
PERFORM PROCESS_DOM USING L_DOCUMENT.
ENDIF.
*& Form get_xml_table
FORM GET_XML_TABLE CHANGING L_XML_TABLE_SIZE TYPE I
L_XML_TABLE TYPE STANDARD TABLE.
* Local variable declaration
DATA: L_LEN TYPE I,
L_LEN2 TYPE I,
L_TAB TYPE TSFIXML,
L_CONTENT TYPE STRING,
L_STR1 TYPE STRING,
C_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,
L_ITAB TYPE TABLE OF STRING.
L_FILENAME = PA_FILE.
* upload a file from the client's workstation
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = L_FILENAME
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = L_XML_TABLE_SIZE
CHANGING
DATA_TAB = L_XML_TABLE
EXCEPTIONS
OTHERS = 19.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Writing the XML document to the screen
CLEAR L_STR1.
LOOP AT L_XML_TABLE INTO L_XML_LINE.
C_CONV = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = L_XML_LINE-DATA REPLACEMENT = SPACE ).
C_CONV->READ( IMPORTING DATA = L_CONTENT LEN = L_LEN ).
CONCATENATE L_STR1 L_CONTENT INTO L_STR1.
ENDLOOP.
L_STR1 = L_STR1+0(L_XML_TABLE_SIZE).
SPLIT L_STR1 AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE L_ITAB.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT L_ITAB INTO L_STR1.
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB IN
L_STR1 WITH SPACE.
WRITE: / L_STR1.
ENDLOOP.
WRITE: /.
ENDFORM. "get_xml_table
*& Form process_dom
FORM PROCESS_DOM USING DOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
DATA: NODE TYPE REF TO IF_IXML_NODE,
ITERATOR TYPE REF TO IF_IXML_NODE_ITERATOR,
NODEMAP TYPE REF TO IF_IXML_NAMED_NODE_MAP,
ATTR TYPE REF TO IF_IXML_NODE,
NAME TYPE STRING,
PREFIX TYPE STRING,
VALUE TYPE STRING,
INDENT TYPE I,
COUNT TYPE I,
INDEX TYPE I.
NODE ?= DOCUMENT.
CHECK NOT NODE IS INITIAL.
ULINE.
WRITE: /.
WRITE: /' DOM-TREE'.
WRITE: /.
IF NODE IS INITIAL. EXIT. ENDIF.
* create a node iterator
ITERATOR = NODE->CREATE_ITERATOR( ).
* get current node
NODE = ITERATOR->GET_NEXT( ).
* loop over all nodes
WHILE NOT NODE IS INITIAL.
INDENT = NODE->GET_HEIGHT( ) * 2.
INDENT = INDENT + 20.
CASE NODE->GET_TYPE( ).
WHEN IF_IXML_NODE=>CO_NODE_ELEMENT.
* element node
NAME = NODE->GET_NAME( ).
NODEMAP = NODE->GET_ATTRIBUTES( ).
WRITE: / 'ELEMENT :'.
WRITE: AT INDENT NAME COLOR COL_POSITIVE INVERSE.
IF NOT NODEMAP IS INITIAL.
* attributes
COUNT = NODEMAP->GET_LENGTH( ).
DO COUNT TIMES.
INDEX = SY-INDEX - 1.
ATTR = NODEMAP->GET_ITEM( INDEX ).
NAME = ATTR->GET_NAME( ).
PREFIX = ATTR->GET_NAMESPACE_PREFIX( ).
VALUE = ATTR->GET_VALUE( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT INDENT NAME COLOR COL_HEADING INVERSE, '=',
VALUE COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN IF_IXML_NODE=>CO_NODE_TEXT OR
IF_IXML_NODE=>CO_NODE_CDATA_SECTION.
* text node
VALUE = NODE->GET_VALUE( ).
WRITE: / 'VALUE :'.
WRITE: AT INDENT VALUE COLOR COL_GROUP INVERSE.
ENDCASE.
* advance to next node
NODE = ITERATOR->GET_NEXT( ).
ENDWHILE.
ENDFORM. "process_dom
Thanks,
Sankar M -
i am new to SAP.
please provide information abt report programming like what are the basic things we have to remember while writing a report program.please provide any link which gives basic information abt report programming with some hands-on practice.hii amar,
Report programming is a simple abap program which deals with presentation of the output to the client.
Report is generally designed when we want to have the output on the screen in a particular manner..
Report has many things attached to it like alv etc.
But basically reports are managed by events. The order of the events are as follows.
Initialization
At selection screen
Start of selection
End of selection
Top of page..
We write the code in these events and this will be executed sequentially. If u want any detailed thing in report. Do revert back.
for eg. in the following code:
*& Report Z_84083_REP *
REPORT z_84083_rep NO STANDARD PAGE HEADING LINE-SIZE 150.
*MESSAGE-ID z_84083_msg.
**********************Database Tables*********************************
TABLES: z84083_train,Z84083_BOOKING.
**************************Selection Screen***************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS: trnno FOR z84083_train-train_no NO INTERVALS.
PARAMETERS: from_st TYPE z84083_train-from_stn,
to-st TYPE z84083_train-to_stn.
SELECTION-SCREEN END OF BLOCK b1.
*************************Internal Table*******************************
DATA: BEGIN OF itab OCCURS 10,
trainno TYPE z84083_train-train_no,
trainname TYPE z84083_train-train_name,
fromstn TYPE z84083_train-from_stn,
tostn TYPE z84083_train-to_stn,
TOTT TYPE z84083_train-TOTAL_TKTS,
END OF itab.
*************************Headings*******************************
DATA:
h1(10) TYPE c VALUE 'Train No',
h2(20) TYPE c VALUE 'Train Name',
h3(20) TYPE c VALUE 'From Stn',
h4(20) TYPE c VALUE 'To Stn'.
DATA : FLD(25) TYPE C,
VAL TYPE z89297_train-trainno.
*************************Report Headings****************************
TOP-OF-PAGE.
WRITE: 'REQUESTER : Rahul Dwivedi',
114'PAGE :',sy-pagno.
WRITE:/ 'PROGRAM : TRAIN REPORT',
114'DATE :',sy-datum.
SKIP 1.
WRITE 60'TRAIN RESERVATION REPORT' COLOR 6 INVERSE ON INTENSIFIED ON.
SKIP 1.
ULINE.
END-OF-PAGE.
ULINE.
*******************Defining the Start Of Selection event*************
START-OF-SELECTION.
PERFORM fetch.
END-OF-SELECTION.
*******************CALLING THE DISPLAY FUNCTION
perfORm display.
AT LINE-SELECTION.
IF sy-lsind = 1.
GET CURSOR FIELD fld VALUE val.
IF fld = 'ITAB-TRAINNO'.
SET PARAMETER ID 'PID' FIELD ITAB-TRAINNO.
SET PARAMETER ID 'PID1' FIELD ITAB-TRAINNAME.
call transaction 'Z84083_TRANS'.
Endif.
ENDIF.
*& Form fetch
text
FORM fetch.
SELECT TRAIN_NO TRAIN_NAME FROM_STN TO_STN TOTAL_TKTS FROM
z84083_train
AS t INTO TABLE itab WHERE
train_no IN trnno AND
from_stn = from_st AND
to_stn = to-st.
SELECT NO_BD NO_AV FROM Z84083_BOOKING INTO TABLE ITAB1 WHERE
TRAIN_NO IN TRNNO.
ENDFORM. "fetch
*& Form DISPLAY
text
FORM display.
ULINE.
FORMAT COLOR 3 INVERSE OFF.
WRITE:/ h1,'|',h2,'|',h3,'|',h4,'|'.
ULINE.
FORMAT COLOR 2 INVERSE OFF.
LOOP AT ITAB.
FORMAT HOTSPOT ON.
WRITE: /(10) ITAB-TRAINNO UNDER h1,'|'.
HIDE ITAB-TRAINNO.
FORMAT HOTSPOT OFF.
WRITE: (20) ITAB-trainname UNDER h2,'|',
(20) ITAB-fromstn UNDER h3,'|',
(20) ITAB-toSTN UNDER h4,'|'.
ENDLOOP.
ULINE.
ENDFORM.
u go thru the program and understand the hierarchy of the various events. -
Hi
Gud Morning . I am Srikanth from hyderabad . I would like to know the following :-
1) Difference between simple reports and complex reports
2) Seqential procedure for creating SIMPLE REPORTS
3) FAQ's on SIMPLE REPORTS
Regards,
M.SrikanthHow many types of reports are there in ABAP and what is the difference between them?
Answer
In ABAP, there are a total of 7 types of reports. They are:
Classical
Interactive
Logical Database
ABAP query
ALV Reports (ALV stands for ABAP List Viewer)
Report Writer/Report Painter
drill down reports
Classical ReportsEdit section
These are the most simple reports. Programmers learn this one first. It is just an output of data using the Write statement inside a loop.
Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT.
Events In Classical Reports.
INTIALIZATION: This event triggers before selection screen display.
AT-SELECTION-SCREEN: This event triggers after proccesing user input still selection screen is in active mode.
START OF SELECTION: Start of selection screen triggers after proceesing selection screen.
END-OF-SELECTION : It is for Logical Database Reporting.
Interactive Reports
As the name suggests, the user can Interact with the report. We can have a drill down into the report data. For example, Column one of the report displays the material numbers, and the user feels that he needs some more specific data about the vendor for that material, he can HIDE that data under those material numbers. And when the user clicks the material number, another report (actually sub report/secondary list) which displays the vendor details will be displayed.
We can have a basic list (number starts from 0) and 20 secondary lists (1 to 21). Events associated with Interactive Reports are: 1. AT LINE-SELECTION 2. AT USER-COMMAND 3. AT PF<key> 4. TOP-OF-PAGE DURING LINE-SELECTION. HIDE statement holds the data to be displayed in the secondary list. sy-lisel : contains data of the selected line. sy-lsind : contains the level of report (from 0 to 21)
Interactive Report Events:
AT LINE-SELECTION : This Event triggers when we double click a line on the list, when the event is triggered a new sublist is going to be generated. Under this event what ever the statements that are been return will be displayed on newly generated sublist.
AT PFn: For predefined function keys...
AT USER-COMMAND : It provides user functions keys.
Logical Database ReportsEdit section
Logical database is another tool for ABAP reports. Using LDB we can provide extra features for ABAP reports.
ABAP Query Reports
ABAP query is another tool for ABAP. It provides efficency for ABAP reports. These reports are very accurate.
Transaction Code : SQ01
Report Writer
Key Concept :
Super users and end users can use Report Painter/Report Writer tools to write their own reports.
Giving them the ability to report on additional fields at their discretion shifts the report maintenance burden to them, saving SAP support groups time and effort normally spent creating and maintaining the reports.
Instead of using ABAP code to write a report in FI and CO, many users build a Report Painter/ Report Writer library using transaction MC27.
However, this workaround has some drawbacks. Little known transaction GRCT solves these problems in most cases, and eliminates the need to use transaction MC27.
ABAP Report Types
ABAP report types are those ones available in some report's attributes screen, i.e. :
Executable program
Function group (containing function modules)
Include
Interface pool
Class pool
Module pool
Subroutine pool
Also ALV means ABAP List Viewer. Most convenient way to use it is through reuse library (cf. transaction se83) available from release 4.6 of SAP R/3.
ALV is available in two modes: list and grid. List mode is good old list processing with standard functionnalities, and grid mode is using a new OCX object displaying grids -
Convert Report Program to PDF file
Hi All,
I need example of converting Report program to PDF file.
I am beginner so please give simple example to understand it properly ..
Please write the description along with the code so that i can understand it...
no long long programs please.
Thanks.
RajHi,
report zabap_2_pdf.
*-- Enhancements: only allow to be run with variant. Then called
*-- program will be transparent to users
*-- TABLES
tables:
tsp01.
*-- STRUCTURES
data:
mstr_print_parms like pri_params,
mc_valid(1) type c,
mi_bytecount type i,
mi_length type i,
mi_rqident like tsp01-rqident.
*-- INTERNAL TABLES
data:
mtab_pdf like tline occurs 0 with header line,
mc_filename like rlgrap-filename.
*-- SELECTION SCREEN
parameters:
p_repid like sy-repid, " Report to execute
p_linsz like sy-linsz default 132, " Line size
p_paart like sy-paart default 'X_65_132'. " Paper Format
start-of-selection.
concatenate 'c:'
p_repid
'.pdf'
into mc_filename.
*-- Setup the Print Parmaters
call function 'GET_PRINT_PARAMETERS'
exporting
authority= space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
in_archive_parameters = space
in_parameters = space
layout = space
mode = space
new_list_id = 'X'
no_dialog= 'X'
user = sy-uname
importing
out_parameters = mstr_print_parms
valid = mc_valid
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
if mstr_print_parms-pdest = space.
mstr_print_parms-pdest = 'LOCL'.
endif.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
mstr_print_parms-linsz = p_linsz.
mstr_print_parms-paart = p_paart.
submit (p_repid) to sap-spool without spool dynpro
spool parameters mstr_print_parms
via selection-screen
and return.
*-- Find out what the spool number is that was just created
perform get_spool_number using sy-repid
sy-uname
changing mi_rqident.
*-- Convert Spool to PDF
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid= mi_rqident
no_dialog = space
dst_device = mstr_print_parms-pdest
importing
pdf_bytecount = mi_bytecount
tables
pdf = mtab_pdf
exceptions
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
others = 12.
call function 'DOWNLOAD'
exporting
bin_filesize = mi_bytecount
filename = mc_filename
filetype = 'BIN'
importing
act_filename = mc_filename
tables
data_tab = mtab_pdf.
* FORM get_spool_number *
* Get the most recent spool created by user/report *
* --> F_REPID *
* --> F_UNAME *
* --> F_RQIDENT *
form get_spool_number using f_repid
f_uname
changing f_rqident.
data:
lc_rq2name like tsp01-rq2name.
concatenate f_repid+0(8)
f_uname+0(3)
into lc_rq2name separated by '_'.
select * from tsp01 where rq2name = lc_rq2name
order by rqcretime descending.
f_rqident = tsp01-rqident.
exit.
endselect.
if sy-subrc ne 0.
clear f_rqident.
endif.
endform." get_spool_number
Regards
Sudheer -
Help needed in report programming
Hi All
I am processing some data on first screen of a report transaction and an output is displayed on second screen. My requirement is that when I press back, I have to come to SAP initial screen.
I have tried all options with 'LEAVE'. Problem is that control doesnt come even once in report, it goes into some standard code so I am unable to make changes..
Kindly help.
Thanks
Dinesh
<LOCKED BY MODERATOR - USE APPROPRIATE TITLES>
<LOCKED BY MODERATOR - URGENT, PLEASE HELP OR SIMILAR ARE FORBIDDEN>
Edited by: Alvaro Tejada Galindo on Aug 18, 2008 5:17 PMHi,
Since it is a report program. U have to set PF status in ur output page (either ALV or any other output format).
In GUI status, triger the function code for BACK.
Then, inside the event AT USER-COMMAND, code LEAVE PROGRAM for the BACK function.
If it is an ALV output, the PF-status and User-command event should be called in the ALV function module.
Regards,
Prem
Maybe you are looking for
-
Can't open a .pdf in IE or FireFox
Every time I try to open a .pdf document in either of the above browers, I get a message saying something like, 'the Adobe Acrobat/Reader that is running cannot be used to view pdf files in a web browser. Please exit Adobe Acrobat/Reader and exit yo
-
Oracle VM 3.0, SSDs and hard partitioning
I am new to virtualization and especially Oracle VM. We have been waiting for Oracle VM 3.0 to come out so that we can build 64 bit hardware drivers (as opposed to 32 Bit in Dom0 on OVM 2.x) for Fusion IO solid state PCI based accelerator cards. Our
-
Over the years I have used LR and then drifted back to iPhoto and PSE, but now want to commit to LR 3. I am combining several family members photos in one place. My stuff: iMac 21.5 (3.06 Gh, ATI graphics), 4G mem., 1TB, backed up to 500G HD and Mo
-
Reg:restart the completed task in human workflow
Dear team, We are working on Oracle soa10g.We have a requiremnt on human tasks. once the task is approved/rejected in bpm worklist, immediately we need to get the task payload and status from BPMworklist and insert in DB. Using human workflow java ap
-
Opening specific ports for video
Hi! I want to open some ports for one specific host on the inside network. I want the host to be able to call out to any host on the internet. What is the easiest way to do this? I have many public IP adresses so the inside host can easily be Natted