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: 

How to Use Subroutune

Former Member
0 Kudos

Hi All

LOOP AT la.

LOOP AT itab.

IF la-begda0(6) = itab-month0(6).

if la-subty = 1000 or la-subty = 1001 or la-subty = 2000 or la-subty = 4000.

a1 = la-begda+6(2).

a2 = 'EL'.

PERFORM leaves USING a1 a2.

endif. endif.

endloop. endloop.

form leaves using

p_a1 like sy-datum

p_a2 type c .

DATA: a1 LIKE sy-datum, a2 TYPE c.

a1 = p_a1.

a2 = p_a2.

if a1+6(2) = '06'.

itab-a6 = a2.

MODIFY itab.

ENDIF.

endform

when the value of a1 pass to form p_a1 and i checked the value of a1 with single qoute or with out qoute . it doesn't come true.

assume that the value is 06.

regards

Ammad

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try like this


DATA: a1 LIKE sy-datum, a2 TYPE c.
LOOP AT la.
LOOP AT itab.
IF la-begda+0(6) = itab-month+0(6).
if la-subty = 1000 or la-subty = 1001 or la-subty = 2000 or la-subty = 4000.
a1 = la-begda+6(2).
a2 = 'EL'.
PERFORM leaves USING a1 a2.
endif. endif.
endloop. endloop.

form leaves using a1 a2 

DATA: p_a1 LIKE sy-datum, p_a2 TYPE c.
p_a1 = a1.
p_a2 = a2.

if p_a1+6(2) = '06'.
itab-a6 = p_a2.
MODIFY itab.
ENDIF.
endform

Regards,

Vik

4 REPLIES 4

Former Member
0 Kudos

Hi,

Try like this


DATA: a1 LIKE sy-datum, a2 TYPE c.
LOOP AT la.
LOOP AT itab.
IF la-begda+0(6) = itab-month+0(6).
if la-subty = 1000 or la-subty = 1001 or la-subty = 2000 or la-subty = 4000.
a1 = la-begda+6(2).
a2 = 'EL'.
PERFORM leaves USING a1 a2.
endif. endif.
endloop. endloop.

form leaves using a1 a2 

DATA: p_a1 LIKE sy-datum, p_a2 TYPE c.
p_a1 = a1.
p_a2 = a2.

if p_a1+6(2) = '06'.
itab-a6 = p_a2.
MODIFY itab.
ENDIF.
endform

Regards,

Vik

kesavadas_thekkillath
Active Contributor
0 Kudos

p_a1 is of type sy-datum thats why .... change it to type c of 2 characters.

Former Member
0 Kudos

you are assigning

a1 = la-begda+6(2)

. That means that only two chars are being transferred to a1. Then you are comparing

if a1+6(2) = '06

searching the seven and eight position of a two position variable. Instead of doing that, compare

if a1 = '06'.

That shoud work.

Former Member
0 Kudos

Hi

The code will work only on the 6th of any month( YYYYMMDD )

Because a1 = la-begda+6(2). Will return the day in a1

So if its 6th it will work else the condition will fail.