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: 

Check & Select statements' behaviour in an HR Report

Former Member
0 Kudos

Hi,

I am new to ABAP & ABAP HR in particular.

I have this report, wich displays a list of employees with info (Name, Date of birth, Start date, End date, Job key, Job title).

To get the job title's text a subroutine is called.

As I see this subroutine is called in a provide loop, wich means it will be proceeded for each valid record.

My Question is, in that subroutine :

First :

The select statement wich normally will fetch for the text of the job title, simply do the fetch without storing the result anywhere (in a WA for e.g. or a variable). How then, in the calling program, the write stament (WRITE (15) t513s-stltx) wich will come after the Perform, can identify that 'job title's text' already fetched ?

Second :

The condition of the Check statement seems to be the opposite of what it should be.

Normally, it should check for e.g if 'sy-langu' is EQ to the 't513s-sprsl', if OK then select should be proceeded if not it shouldn't.

But it seems to do the opposite ?

******************************************************************************************

REPORT zpsol030 LINE-SIZE 100.

*-- Declaration

TABLES: pernr, T513S. "Job Titles

INFOTYPES: 0001, "Organ. Assignment

                    0002. "Personal Data

*-- Processing GET pernr.

PROVIDE stell ename FROM p0001

               gbdat FROM p0002 BETWEEN pn-begda and pn-endda.

     IF p0001_valid EQ 'X'.

          IF p0001-stell NE space.

               PERFORM re513s.

               WRITE : / pernr-pernr, sy-vline,

                              (20) p0001-ename, sy-vline,

                              p0002-gbdat, sy-vline,

                              p0001-stell, sy-vline,

                              (15) t513s-stltx, sy-vline,

                              p0001-begda, sy-vline,

                              p0001-endda.

          ENDIF.

     ENDIF.

ENDPROVIDE.

*-------------------------------------------------------------*

* FORM RE513S *

*-------------------------------------------------------------*

* Read Job Title *

*-------------------------------------------------------------*

FORM re513s.

     CHECK sy-langu NE t513s-sprsl OR

               p0001-stell NE t513s-stell OR

               p0001-begda LT t513s-begda OR

               p0001-begda GT t513s-endda.

     SELECT * FROM t513s WHERE sprsl EQ sy-langu  AND stell EQ p0001-stell

          AND endda GE p0001-begda 

          AND begda LE p0001-begda.

     ENDSELECT.

    

     IF sy-subrc NE 0.

          CLEAR t513s.

          WRITE: / pernr-pernr, ‘No entry in T513S for job key’ (001), p0001-stell.

          REJECT.

     ENDIF.

ENDFORM.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

just something to the first issue:

Data from the select is stored in wa, defined in 'tables' statement.

If no data is fetched, the write statement in the calling program is never reached because of the reject.

Hope that helps a little bit :-).

regards Alex

4 REPLIES 4

Former Member
0 Kudos

hi seif,

As this is logical database everything is managed in the logical database itself.

It is storing in work areas which is defined in the logical database.

Former Member
0 Kudos

Hi,

just something to the first issue:

Data from the select is stored in wa, defined in 'tables' statement.

If no data is fetched, the write statement in the calling program is never reached because of the reject.

Hope that helps a little bit :-).

regards Alex

0 Kudos

Do you mean that for each structure or table defined in 'tables' statement, an associated WA will be automatically created for it ?

0 Kudos


thats how i understand the sap help:

This statement is not allowed in classes and declares a data object table_wa as a table work area whose data type is adopted from

the identically named structured data type table_wa

from the ABAP Dictionary. table_wa must be defined as a

flat structure in the ABAP

Dictionary. You can specify database tables or views for table_wa.

Suggestion on second issue:

not quite sure but i would say: If the check is not passed, it means the data in the t513 structure  is identical to the data the select will deliver, so you don´t have to execute the select, because you already have the data. Maybe because the two employees have the some job assigned, or there is more than 1 entry in pa0001 for this employee in the selection time.