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: 

Logic for Populating a Work Area

Former Member
0 Kudos

Hi Gurus,

I have a standard sap structure KNWEV. In the structure the values will get populated as give below.

For an Unloading point for different days ie for Monday the times for unloading will be

Monday 8 30 12 30 14 30 16 30.

Tuesday 9 30 12 30 14 30 16 30

The values will get populated for all the days for an unloading point. and its stored in structure as below.

KNWEV Field names and Field Values

Unloading_point Monday1 Monday2 Monday3 Monday4 Tuesday1 Tuesday2 Tuesday3 Tuesday4 etc

-


.

Dock A 8 30 12 30 14 30 16 30 9 30 12 30 14 30 16 30

Suppose for a unloading date let it be 18 / March / 2009 , it is a Tuesday

I want to populate work area in my program with Unloading point and Time for Tuesday taking values from KNWEV

Work Area

Unloading point Tuesday1 Tuesday2 Tuesday3 Tuesday4 .

-


Dock A 9 30 12 30 14 30 16 30

Please let me know how can i move fields from structure to my work area taking the field names as Monday1 Monday2 .. and so on

Edited by: Avi on Mar 18, 2009 12:11 AM

3 REPLIES 3

Former Member
0 Kudos

Hi,

Use the code below...

data weekday type DTRESR-WEEKDAY
data string type string.

call function date_to_day
exporting
date = sy-datum
importing
weekday = weekday.

if weekday CS 'WED'.
   string = 'WEDNESDAY'.
elseif weekday CS 'SAT'.
   string = 'SATURDAY'.
endif.                                       " For all other days it takes it automatically....

read table itab into wa_knwev with key unloading_point = weekday.
" I don't know whether which variable contains the weekday in the internal table so i have used the variabel unloading point...
" The above read statement will get the record in the work area for the date you mention in the FM...

I hope this is what you required ...

if this is not meeting the requirement please do specify a bit more on your requirement

Regards,

Siddarth

0 Kudos

Hi Sidharth,

Thanks for your reply.

But my table field name is MONDAY1

For example see table KNVA there you can see the table field names

For Monday it has 4 fields in the table - MOAB1 , MOBI1,MOAB2,MOBI2 .

So if from function module Date_to_Day gives me MONDAY

then I have to move values from these fields MOAB1 , MOBI1,MOAB2,MOBI2 to my work area.

Hope you got my requirement.

Regards

Avi

0 Kudos

Ah!!!!

Apologize for misunderstanding the requirement...

I got your requirement...

use the code given below...

data weekday type DTRESR-WEEKDAY
data string type string.
 
call function date_to_day
exporting
date = sy-datum
importing
weekday = weekday.

if weekday CS 'MONDAY'.
  read table itab into wa_knwev with key unloading_point = value_for_unloading_point
       transporting unloading_point MOAB1 MOBI1 MOAB2 MOBI2. 
elseif weekday cs 'TUESDAY'.
  read table itab into wa_knwev with key unloading_point = value_for_unloading_point
       transporting unloading_point DIAB1 DIBI1 DIAB2 DIBI2.
 
"like wise for other days you can do it this way....
elseif weekday CS 'WED'.
  
elseif weekday CS 'SAT'.
   string = 'SATURDAY'.
endif.