Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

basic report programming

Former Member
0 Kudos

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.

7 REPLIES 7

Former Member
0 Kudos

Former Member
0 Kudos

hi,

ABAP Editor for writing and editing program code

ABAP Dictionary for processing database tables and retrieving global types

Menu Painter for designing the user interface (menu bar, standard toolbar, application toolbar)

(see Interfaces)

Screen Painter for designing screens (dynamic programs) for user dialogs

Function Builder for displaying and processing function modules (subroutines with defined interfaces

that are available throughout the system)

Class Builder for displaying and processing central classes

There are two different ways to go about using these tools:

Either you call each individual tool and edit the corresponding Repository objects.

You must then call the next tool for the next set of objects...

Or you work with the Object Navigator: This transaction provides you with a tree-like overview of all

objects within a development class or program.

Sample program code.

TABLES sbc400_carrier

DATA wa_scarr TYPE scarr .

SELECT SINGLE * FROM scarr

INTO CORRESPONDING FIELDS OF wa_scarr

WHERE carrid = pa_car .

IF sy-subrc = 0

MOVE-CORRESPONDING wa_scarr TO sbc400_carrier.

CALL SCREEN 100 .

MOVE-CORRESPONDING

sbc400_carrier TO wa_scarr.

WRITE

:

wa_scarr-carrid ,

wa_scarr-carrname ,

wa_scarr-currcode .

ENDIF.

-


ABAP programs are made up of individual statements.

Each statement ends with a period.

The first word in a statement is called a keyword.

Words must always be separated by at least one space.

Statements can be indented.

Statements can take up more than one line.

You may have multiple statements in a single line.

Consecutive statements with identical initial keywords can be condensed into one chained statement:

The TABLES statement always refers to the global type of a flat structure that is defined in the ABAP

Dictionary. The structure type for the data object in the program is taken from the Dictionary. The data

object name is identical to the name of the structure type. TABLES structures are stored technically

slightly differently to local data objects that are defined using the DATA statement. They are normally

used as a structure for the interface to the screen.

The DATA statement is usually used to define local data objects. The data object type is specified

using the TYPE addition.

The PARAMETERS statement defines not only an elementary data object, but also an input field on

the standard selection screen that is processed at the start of the program.

The statement CALL SCREEN calls a screen.

A screen must be created using the Screen Painter tool.

A screen is an independent Repository object, but belongs to the program.

The SELECT statement ensures that data is read from the database. In order to read a record from a

database table, the following information must be passed to the database:

WRITE statements display field contents, formatted according to their data type, as a list.

Consecutive WRITE statements display output in the same output line. Output continues in the next line

when the present one is full.

From which database table is the data read? (FROM clause)

How many lines are read? The SINGLE addition shows that only one line is read.

Hope this is helpful, Do reward.

Former Member
0 Kudos

Hai Amar,

'Report' as the name suggests, it is a report generated for a specific purpose.

e.g., Headmaster of a school may want to view the performance of a particular class students. In these kind of scenarios, we use report programming technique.

Look at some examples now,

http://www.sapmaterial.com/?gclid=CNGLkbL5mJECFRE2egodhERFHA

All the best.

Former Member
0 Kudos

hi,

Creating Reports

ABAP/4 Language elements

A report consists of individual statements that start with a reserved word and end with a period.

E.g.

START-OF-SELECTION.

WRITE XYZ.

MOVE SALES TO TOTAL_SALES.

The first word of statement (the reserved word) determines the meaning of the whole statement.

Declarative Language Elements

Declarative language elements declare the data items that can be addressed in the report:

DATA, TABLES, PARAMETERS, SELECT-OPTIONS.

Timing Language Elements

Timing language elements specify the point in time (the event) when to execute a process.

START-OF-SELECTION, END-OF-SELECTION, AT SELECTION SCREEN.

Control Language Element

Control language elements control the processing flow:

IF…ENDIF, WHILE…. ENDWHILE, CASE…ENDCASE.

Operational Language Element

Operational language elements process the data at certain times under certain conditions.

WRITE, MOVE.

Remark: For clarity you should list all declarative language elements together at the beginning of a report in a declaration section.

WRITE CITY UNDER STREET.

Note: The ABAP/4 report language has no format restrictions. This means that you can enter the statements (instructions) unformatted, you can indent them, you can write statements in one line, or can spread one statement over several lines. Separate the words with a statement by at least one blank character. The end of line corresponds to a blank character. A statement thus can be longer than one line.

There are two ways of indicating comments in a report:

If the whole line is a comment, type * in the first column

  • This is a comment line

If the rest of the line is a comment, type “ before the comment

IF SY-SUBRC = 0. “ Query return code.

You can insert comment lines anywhere in the report. Comments indicated by “ are equivalent to blank character.

Combining similar statements to one statement

Consecutive sentences (statements) with an identical beginning can be combined to a chain instruction.

Instead of the statement

WRITE EMP_CODE.

WRITE EMP_NAME.

WRITE EMP_ADDRESS.

You can form a chain statement:

WRITE: EMP_CODE, EMP_NAME, EMP_ADDRESS.

Remark: Put a colon between the identical beginning of the statement and the variable part. Separate the components of the variable part by commas. To improve readability, you can use blanks before and after the separator characters.

do this program:

ABAP Inputs:

Create an ABAP program

ABAP will have following parameters.

P_STRING - input string. The input should be taken in LOWERCASE.

FLAGS should be displayed as radiobutton. Depending upon the value of the selected FLAG, corresponding function will be performed on the input string.

T_FLAG – to convert the string to UPPERCASE

L_FLAG – to return the length of the string

S_FLAG – to remove leading zeroes in the string

O_FLAG – to return subset of string starting from offset P_OFFSET and having length P_LENGTH.

P_OFFSET and P_LENGTH are parameters to take in the offset and length of the substring.

reward if its useful

Former Member
0 Kudos

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.