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

Select Field

Former Member
0 Likes
908

Dear Abap Gurus

SELECT COUNT( * ) as count

RJVNAM

RECVIND

RACCT

CCWBS

JIBCL

JIBSB

SUM( hsl01 ) as HSL01

SUM( hsl02 ) as HSL02

SUM( hsl03 ) as HSL03

SUM( hsl04 ) as HSL04

SUM( hsl05 ) as HSL05

SUM( hsl06 ) as HSL06

SUM( hsl07 ) as HSL07

SUM( hsl08 ) as HSL08

SUM( hsl09 ) as HSL09

SUM( hsl10 ) as HSL10

SUM( hsl11 ) as HSL11

SUM( hsl12 ) as HSL12

Above is the part of internal table which contain the selected fields and field HSL01 to HSL12 representing the consecutive month. I have senario if user select month 6 (June) which represent field HSL06 what is the best way in the abap script that I’m able to select field from HSL01 to HSL06.

Thanks

Regards

Adis

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
797

Hi,

You can use Do---- varying---from-- next command as given below with some restriction of counter on the basis of ur period.

SELECT bukrs " Company Code

ryear " Fiscal Year

racct " Account No.

hslvt " Balance carried forward

hsl01 " Total Transactions in the period

hsl02 " Total Transactions in the period

hsl03 " Total Transactions in the period

hsl04 " Total Transactions in the period

hsl05 " Total Transactions in the period

hsl06 " Total Transactions in the period

hsl07 " Total Transactions in the period

hsl08 " Total Transactions in the period

hsl09 " Total Transactions in the period

hsl10 " Total Transactions in the period

hsl11 " Total Transactions in the period

hsl12 " Total Transactions in the period

hsl13 " Total Transactions in the period

hsl14 " Total Transactions in the period

hsl15 " Total Transactions in the period

hsl16 " Total Transactions in the period

FROM glt0

INTO TABLE it_glt0

WHERE bukrs IN s_bukrs

AND ryear EQ g_year.

IF sy-subrc EQ c_zero.

SORT it_glt0 BY bukrs racct.

LOOP AT it_glt0 INTO wa_glt0.

DATA l_counter TYPE i VALUE 0.

  • For Horizontal movement in a work area as we need to add the amount

  • from hsl01 to hslXX where XX is the period

DO VARYING l_amount1 FROM wa_glt0-hslvt NEXT wa_glt0-hsl01.

wa_glt0-amount = wa_glt0-amount + l_amount1.

  • l_counter = l_counter + 1.

CLEAR l_amount1.

IF l_counter NE c_zero.

IF l_counter EQ g_period+1(2).

EXIT.

ENDIF.

ENDIF.

l_counter = l_counter + 1.

ENDDO.

ENDLOOP.

4 REPLIES 4
Read only

Former Member
0 Likes
797

take one common variable for that month which user selects,and then write condition according to that.

you can write like suppose user has selected 6 :

select upto n rows(where n = no selected by user).

or put a loop and select.

Read only

0 Likes
797

Hi

You can try with options like,

Select (V_FIELDS)

where ....

Where you variable V_FIELDS will be populated based on the conditions. You should also give your fixed fields in this variable ... You can get more information by checking Dynamic Selects from SAP Help

~ Ranganath

Read only

Former Member
0 Likes
798

Hi,

You can use Do---- varying---from-- next command as given below with some restriction of counter on the basis of ur period.

SELECT bukrs " Company Code

ryear " Fiscal Year

racct " Account No.

hslvt " Balance carried forward

hsl01 " Total Transactions in the period

hsl02 " Total Transactions in the period

hsl03 " Total Transactions in the period

hsl04 " Total Transactions in the period

hsl05 " Total Transactions in the period

hsl06 " Total Transactions in the period

hsl07 " Total Transactions in the period

hsl08 " Total Transactions in the period

hsl09 " Total Transactions in the period

hsl10 " Total Transactions in the period

hsl11 " Total Transactions in the period

hsl12 " Total Transactions in the period

hsl13 " Total Transactions in the period

hsl14 " Total Transactions in the period

hsl15 " Total Transactions in the period

hsl16 " Total Transactions in the period

FROM glt0

INTO TABLE it_glt0

WHERE bukrs IN s_bukrs

AND ryear EQ g_year.

IF sy-subrc EQ c_zero.

SORT it_glt0 BY bukrs racct.

LOOP AT it_glt0 INTO wa_glt0.

DATA l_counter TYPE i VALUE 0.

  • For Horizontal movement in a work area as we need to add the amount

  • from hsl01 to hslXX where XX is the period

DO VARYING l_amount1 FROM wa_glt0-hslvt NEXT wa_glt0-hsl01.

wa_glt0-amount = wa_glt0-amount + l_amount1.

  • l_counter = l_counter + 1.

CLEAR l_amount1.

IF l_counter NE c_zero.

IF l_counter EQ g_period+1(2).

EXIT.

ENDIF.

ENDIF.

l_counter = l_counter + 1.

ENDDO.

ENDLOOP.

Read only

former_member404244
Active Contributor
0 Likes
797

Hi,

use select-options for the month field...

select-options : s_month for ...

select teh data from db table into table itab where month in s_month.

now what ever the user gives the values in s_month,,accordingly u will get the data..

Regards,

Nagaraj