cancel
Showing results for 
Search instead for 
Did you mean: 

Entering data in internal table column if given condition is satisfied

Jay_Kamdar
Participant
0 Kudos

I have to write code regarding user availability if user is on leave on particular day than that day should be mark as 'L'.

And display it in webdynpro table.Structure of table is Name day1 day2 day3 ... day31.

Am not getting how to insert data in internal table

Accepted Solutions (1)

Accepted Solutions (1)

chengalarayulu
Active Contributor
0 Kudos

Jay,

Let there are two tables, one is employee attendance which includes leaves also and another is to insert leave days...

IT_ATTENDANCE_TAB,

IT_LEAVE_DAYS.

loop at IT_ATTENDANCE_TAB into IS_ATTENDANCE_TAB.

if IS_ATTENDANCE_TAB-LEAVE = <abap_true> "" this is your check condition, i've mentioned for demo

     IS_LEAVE_DAYS-DAY = IS_ATTENDANCE_TAB-DAY.

append IS_LEAVE_DAYS to IT_LEAVE_DAYS.

endif.

endloop.

hope you understood.

Jay_Kamdar
Participant
0 Kudos

But while using append it creates a new in table row, i want user and days in a single row

Example

User          day1   day2       day3 ...      day31

------------------------------------------------------------------------

username    L        L            P

chengalarayulu
Active Contributor
0 Kudos

ok, now I understood,

for this, you can make use of field-symbols for creating structure or you can define your own structure..

types: begin of ty_leave_days,

               day1 type char10,

               day2 type char10,

               --------

               -------

          end of ty_leave_days.

Answers (1)

Answers (1)

amy_king
Active Contributor
0 Kudos

Hi Jay,

To assign a value to a particular "day" in your structure, you could use ASSIGN COMPONENT.

  ASSIGN COMPONENT comp OF STRUCTURE struc TO <fs>.

For example.

  FIELD-SYMBOLS <day> TYPE CHAR01. " typed same as ls_leave_days-dayN

  ASSIGN COMPONENT 'DAY1' OF STRUCTURE ls_leave_days TO <day>.

This will result in the field-symbol <day> pointing to field LS_LEAVE_DAYS-DAY1, and you can then assign a value to the individual field:

  <day> = 'L'. " on leave

Cheers,

Amy