Application Development and Automation 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: 
Read only

Date code with example

Former Member
0 Likes
1,654

Hi Experts,

How will the following code work....

lv_date = ls_billing-bill_date.

CONDENSE lv_date.

lv_bill_date = lv_date(8).

lv_billplan_date = lv_bill_date.

lv_billplan_date+6(2) = '01'.

lv_billfrom_date = lv_billplan_date.

Please explain me with an example.

Regards,

Sangeeta.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,035

hi sangeeta,

suppose lv_billplan_date = 20080128 28th january in yyyymmdd format..

now lv_billplan_date+6(2) will travle 6 places in lv_billplan_date

and reach to '1' after this it has 2 more places to traverse that is '28' DAY, so the code is hardcoding and changing it forcibly to '01' ..

so the output will be 20080101 [date is changed to 1st january]

hope it helps

Reward points if useful

Rohan Malik

5 REPLIES 5
Read only

Former Member
0 Likes
1,035

Hi,

if the date is

20080204

then it will return

yyyymmdd

20080201

it is hardcoding the day of the month as 01

the last two characteres are replaced with 01

regards,

Venkatesh

Read only

Former Member
0 Likes
1,035

Hi,

take for example:

lv_date = ' 2007010'.

condense will remove the gaps

and lv_date = '2007010'.

lv_bill_date = 2007010

lv_billplan_date = lv_bill_date = 2007010

lv_billplan_date+6(2) = 01

lv_billfrom_date = lv_billplan_date = 20070101.

if u chk out this code in debug mode evrthing will be clear..

reward appropriate points.

regards,

Mansi

Read only

Former Member
0 Likes
1,036

hi sangeeta,

suppose lv_billplan_date = 20080128 28th january in yyyymmdd format..

now lv_billplan_date+6(2) will travle 6 places in lv_billplan_date

and reach to '1' after this it has 2 more places to traverse that is '28' DAY, so the code is hardcoding and changing it forcibly to '01' ..

so the output will be 20080101 [date is changed to 1st january]

hope it helps

Reward points if useful

Rohan Malik

Read only

Former Member
0 Likes
1,035
 
lv_date = ls_billing-bill_date.  "for example internal table field has value ' 20080204' 
                                 "with some leading spaces or trailing spaces 
CONDENSE lv_date.  "here date value will condense i.e. removes 
                   "any leading or trailing spaces. 
                    
lv_bill_date = lv_date(8). "assigning date value i.e. 20080204 to lv_bill_date 

lv_billplan_date = lv_bill_date. "assigning lv_bill_date to lv_billplan_date 

lv_billplan_date+6(2) = '01'. "changing date as staring date of 
                              "month i.e. 20080204 to 20080201 

lv_billfrom_date = lv_billplan_date. "assigning lv_billplan_date to lv_billfrom_date 

Read only

NAeda
Contributor
0 Likes
1,035

for exp Is_billing-bill_date = '20080402'

1. now lv_date will be '20080402'

2.

3.lv_bill_date is eight characters of lv_date ie '20080402'.

4. lv_billplan_date is 20080402

5.lv_billplan_date+6(2) is 02 that is replace by 01.

6. lv_billfrom_date is 200080401.

so the date field is changed 02 to 01.

Thnks

Regards

Narsim