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

perform statements

Former Member
0 Likes
2,636

Hi Experts,

how to use perform statement for this select query .,., guide me with codes

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r WHERE massn IN ('41' , '40') AND begda BETWEEN date11 AND date21 ."#EC CI_NOFIRST

DESCRIBE TABLE it_pb4000r LINES t.

MOVE t TO wa_output-pweek.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r2 WHERE massn IN ('41' , '40') AND begda BETWEEN output AND sy-datum."#EC CI_NOFIRST

DESCRIBE TABLE it_pb4000r2 LINES t2.

MOVE t2 TO wa_output-month.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r2 WHERE massn IN ('41' , '40') AND begda BETWEEN output AND sy-datum."#EC CI_NOFIRST

DESCRIBE TABLE it_pb4000r2 LINES t2.

MOVE t2 TO wa_output-month.

Thanks,

ThiruKumaran. R

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,276

CLEAR T.

PERFORM READ_DATA TABLES IT_PB4000R

USING DATE11

DATE21

CHANGING T.

MOVE T TO WA_OUTPUT-PWEEK.

CLEAR T2.

PERFORM READ_DATA TABLES IT_PB4000R2

USING OUTPUT

SY-DATUM

CHANGING T2.

MOVE T2 TO WA_OUTPUT-MONTH.

CLEAR T2.

PERFORM READ_DATA TABLES IT_PB4000R2

USING OUTPUT

SY-DATUM

CHANGING T2.

MOVE T2 TO WA_OUTPUT-MONTH.

&----


*& Form READ_DATA

&----


  • text

----


  • -->P_IT_PB4000R text

  • -->P_DATE11 text

  • -->P_DATE21 text

  • <--P_WA_OUTPUT text

----


FORM READ_DATA TABLES P_IT_PB4000R STRUCTURE IT_PB4000R

USING P_DATE1

P_DATE2

CHANGING P_T.

SELECT PERNR FROM PB4000 INTO TABLE P_IT_PB4000R WHERE MASSN IN ('41' , '40') AND BEGDA BETWEEN P_DATE1 AND P_DATE2 ."#EC CI_NOFIRST

DESCRIBE TABLE P_IT_PB4000R LINES P_T.

ENDFORM. " READ_DATA

6 REPLIES 6
Read only

Former Member
0 Likes
1,276

Hi,

PERFORM statemnt is used to call a subroutine in a program.

For ex.:

PERFORM GET_DATA.

FORM GET_DATA.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r WHERE massn IN ('41' , '40') AND begda BETWEEN date11 AND date21 ."#EC CI_NOFIRST
DESCRIBE TABLE it_pb4000r LINES t.
MOVE t TO wa_output-pweek.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r2 WHERE massn IN ('41' , '40') AND begda BETWEEN output AND sy-datum."#EC CI_NOFIRST
DESCRIBE TABLE it_pb4000r2 LINES t2.
MOVE t2 TO wa_output-month.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r2 WHERE massn IN ('41' , '40') AND begda BETWEEN output AND sy-datum."#EC CI_NOFIRST
DESCRIBE TABLE it_pb4000r2 LINES t2.
MOVE t2 TO wa_output-month.

ENDFORM.

Regards,

Saba

Read only

Former Member
0 Likes
1,276

PERFORM <NAME> USING/CHANGING..<VALUES>

where VALUES are the fields which u r using in the select query.

Press F1 in PERFORM u will get more idea.

Amresh.

Read only

Former Member
0 Likes
1,276

PERFORM f_fill_output USING date11 date21 'week' .

PERFORM f_fill_output USING output sy-datum 'month'.

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

FORM f_fill_output USING date1 TYPE sy-datum

date2 TYPE sy-datum

var type char5.

SELECT pernr

FROM pb4000

INTO TABLE it_pb4000r

WHERE massn IN ('41' , '40')

AND begda BETWEEN date11 AND date21 .

IF var EQ week.

DESCRIBE TABLE it_pb4000r LINES t.

MOVE t TO wa_output-pweek.

ELSEIF var EQ month.

DESCRIBE TABLE it_pb4000r2 LINES t2.

MOVE t2 TO wa_output-month.

ENDIF.

ENDFORM

Read only

VikasB
Active Participant
0 Likes
1,276

Hi,

You can write your code as below.

PERFORM get_pernr tables it_pb4000r

using date11

date 21

changing g_lines

wa_output-pweek

FORM GET_PERNR tables <i_tab>

using p_date11

p_date21

changing p_g_lines

p_output-field

SELECT pernr

FROM pb4000

INTO TABLE <i_tab>

WHERE massn IN ('41' , '40')

AND begda BETWEEN p_date11 AND p_date21.

DESCRIBE TABLE <i_tab> LINES p_g_lines.

MOVE p_g_lines TO p_output-field.

ENDFORM. " GET_PERNR

After this you can use this perform with changing the paramters.

Regards,

Vikas

Read only

Former Member
0 Likes
1,276

Hi Thiru,

We use perform is a statement that is used to define a subroutine.

The 3 select queries which you wrote can be handled by each subroutine like as shown

Perform Day.

Perform Week.

Perform Month.

Form Day.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r WHERE massn IN ('41' , '40') AND begda BETWEEN date11 AND date21 ."#EC CI_NOFIRST

DESCRIBE TABLE it_pb4000r LINES t.

MOVE t TO wa_output-pweek.

Endform.

Form Week.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r2 WHERE massn IN ('41' , '40') AND begda BETWEEN output AND sy-datum."#EC CI_NOFIRST

DESCRIBE TABLE it_pb4000r2 LINES t2.

MOVE t2 TO wa_output-month.

Endform.

Form Month.

SELECT pernr FROM pb4000 INTO TABLE it_pb4000r2 WHERE massn IN ('41' , '40') AND begda BETWEEN output AND sy-datum."#EC CI_NOFIRST

DESCRIBE TABLE it_pb4000r2 LINES t2.

MOVE t2 TO wa_output-month.

Endform.

Normally when we thread the work we use to declare this type of subroutines(perform)

Cheers!!

VEnk@

Read only

Former Member
0 Likes
1,277

CLEAR T.

PERFORM READ_DATA TABLES IT_PB4000R

USING DATE11

DATE21

CHANGING T.

MOVE T TO WA_OUTPUT-PWEEK.

CLEAR T2.

PERFORM READ_DATA TABLES IT_PB4000R2

USING OUTPUT

SY-DATUM

CHANGING T2.

MOVE T2 TO WA_OUTPUT-MONTH.

CLEAR T2.

PERFORM READ_DATA TABLES IT_PB4000R2

USING OUTPUT

SY-DATUM

CHANGING T2.

MOVE T2 TO WA_OUTPUT-MONTH.

&----


*& Form READ_DATA

&----


  • text

----


  • -->P_IT_PB4000R text

  • -->P_DATE11 text

  • -->P_DATE21 text

  • <--P_WA_OUTPUT text

----


FORM READ_DATA TABLES P_IT_PB4000R STRUCTURE IT_PB4000R

USING P_DATE1

P_DATE2

CHANGING P_T.

SELECT PERNR FROM PB4000 INTO TABLE P_IT_PB4000R WHERE MASSN IN ('41' , '40') AND BEGDA BETWEEN P_DATE1 AND P_DATE2 ."#EC CI_NOFIRST

DESCRIBE TABLE P_IT_PB4000R LINES P_T.

ENDFORM. " READ_DATA