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

how to use offset for select-option parameter ?

satish_kumar127
Participant
0 Likes
2,002

Hi experts

could anybody please let me know how to use offset for select-option parameter. i can able to use offset for table fields, variabiles and all , but don't know how to use for parameters.

following is my code

SELECT-OPTIONS: s_prctr  FOR vbsegs-prctr OBLIGATORY.


here "prctr"  length is 10.


i'm using two tables  1. vbsegd-bupla

                                2. vbsegs-prctr


here prctr+6(4) = bupla.


"Bupla" length is 4

SELECT belnr gjahr bukrs bupla sgtxt buzei FROM vbsegd INTO CORRESPONDING FIELDS OF TABLE it_vbsegd FOR ALL ENTRIES IN it_vbkpf

                                                             WHERE belnr = it_vbkpf-belnr

                                                               AND gjahr = it_vbkpf-gjahr

                                                               AND bukrs = it_vbkpf-bukrs

                                                               AND bupla IN s_prctr.  


the above statement is not working as prctr and bupla lenths are different. here i want to use offset.


SELECT belnr gjahr bukrs prctr sgtxt buzei FROM vbsegs INTO CORRESPONDING FIELDS OF TABLE it_vbsegs FOR ALL ENTRIES IN it_vbkpf

                                                            WHERE belnr = it_vbkpf-belnr

                                                              AND gjahr = it_vbkpf-gjahr

                                                              AND bukrs = it_vbkpf-bukrs

                                                              AND prctr IN s_prctr.


this is working as prctr and s_prctr lengths are equal.



could anybody please help me out in this.


Thanks in advance.


regards


satish

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,644

Hi Satish,

You can write following logic:

1. Define new range table r_itab of BUPLA type.

2. If S_PRCTR-high is initial then go to step-3 else go to step-4

3. Loop on S_PRCTR and then offset the PRCTR value, further append it to range table r_itab(fiel-Low)

4. Append S_PRCTR-low, S_PRCTR-high value into range table-low,high value after offsetting the value

3. Further use the range table r_itab in Select query.

Regards,

Sudeesh Soni

Hi experts

could anybody please let me know how to use offset for select-option parameter. i can able to use offset for table fields, variabiles and all , but don't know how to use for parameters.

following is my code

SELECT-OPTIONS: s_prctr  FOR vbsegs-prctr OBLIGATORY.


here "prctr"  length is 10.


i'm using two tables  1. vbsegd-bupla

                                2. vbsegs-prctr


here prctr+6(4) = bupla.


"Bupla" length is 4

SELECT belnr gjahr bukrs bupla sgtxt buzei FROM vbsegd INTO CORRESPONDING FIELDS OF TABLE it_vbsegd FOR ALL ENTRIES IN it_vbkpf

                                                             WHERE belnr = it_vbkpf-belnr

                                                               AND gjahr = it_vbkpf-gjahr

                                                               AND bukrs = it_vbkpf-bukrs

                                                               AND bupla IN s_prctr.  


the above statement is not working as prctr and bupla lenths are different. here i want to use offset.


SELECT belnr gjahr bukrs prctr sgtxt buzei FROM vbsegs INTO CORRESPONDING FIELDS OF TABLE it_vbsegs FOR ALL ENTRIES IN it_vbkpf

                                                            WHERE belnr = it_vbkpf-belnr

                                                              AND gjahr = it_vbkpf-gjahr

                                                              AND bukrs = it_vbkpf-bukrs

                                                              AND prctr IN s_prctr.


this is working as prctr and s_prctr lengths are equal.



could anybody please help me out in this.


Thanks in advance.


regards


satish

5 REPLIES 5
Read only

Former Member
0 Likes
1,645

Hi Satish,

You can write following logic:

1. Define new range table r_itab of BUPLA type.

2. If S_PRCTR-high is initial then go to step-3 else go to step-4

3. Loop on S_PRCTR and then offset the PRCTR value, further append it to range table r_itab(fiel-Low)

4. Append S_PRCTR-low, S_PRCTR-high value into range table-low,high value after offsetting the value

3. Further use the range table r_itab in Select query.

Regards,

Sudeesh Soni

Read only

0 Likes
1,644

Hi sudeesh,

Thanks for your kt. your post was helped me to resolve my issue.

Thanks for the prompt reply.

Regards

satish

Read only

Former Member
0 Likes
1,644

Below code will work for you.

SELECT-OPTIONS: s_prctr  FOR vbsegs-prctr OBLIGATORY.

RANGES: s_bupla FOR vbsegd-bupla.

s_bupla[] = s_prctr[].

DELETE ADJACENT DUPLICATES FROM s_bupla.

SELECT belnr gjahr bukrs bupla sgtxt buzei FROM vbsegd INTO CORRESPONDING FIELDS OF TABLE it_vbsegd FOR ALL ENTRIES IN it_vbkpf

                                                              WHERE belnr = it_vbkpf-belnr

                                                                AND gjahr = it_vbkpf-gjahr

                                                                AND bukrs = it_vbkpf-bukrs

                                                                AND bupla IN s_bupla.

Read only

0 Likes
1,644

Hi Digesh,

Thank you for  your valuable time . my issue has been resolved with your helpful reply.

Thanks a lot again.

regards

satish

Read only

Former Member
0 Likes
1,644

Instead of s_bupla[] = s_prctr[].

Use below logic.

LOOP AT s_prctr.

   s_bupla-sign  = s_prctr-sign.

   s_bupla-option = s_prctr-option.

   s_bupla-low  = s_prctr-low+6(4).

   s_bupla-high = s_prctr-high+6(4).

   APPEND s_bupla.

ENDLOOP.