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

Problem in SAP SET while firing select query

Former Member
0 Likes
743

Hi Experts,

please check my code below

DATA: BEGIN OF ibsis OCCURS 100

         ebeln LIKE bseg-ebeln,   

         ebelp LIKE bseg-ebelp,   

         bsis LIKE bsis,          

         ldgrp TYPE fagl_ldgrp.   

DATA: END OF ibsis.              

TYPES : BEGIN OF TY_ZFINITEMCAT,

               pstyv TYPE vbap-pstyv,

             END OF TY_ZFINITEMCAT.

DATA : GT_ZFINITEMCAT TYPE STANDARD TABLE OF TY_ZFINITEMCAT.

FIELD-SYMBOLS : <fs_ZFINITEMCAT> TYPE TY_ZFINITEMCAT.


DATA: l_item_catecory TYPE pstyv.


SELECT VALFROM

          INTO TABLE GT_ZFINITEMCAT

          FROM SETLEAF

          WHERE SETNAME EQ 'ZFIN_ITEMCAT'.


LOOP AT ct_ibsis[] ASSIGNING <ibsis>.

"Check if we can find one item of the wrong category, if so then we remove the documents.

     SELECT SINGLE pstyv INTO l_item_catecory

       FROM vbap

       WHERE vbeln = <ibsis>-bsis-zuonr

         AND pstyv NOT IN GT_ZFINITEMCAT.  "getting error here (The line structure of the table "GT_ZFINITEMCAT" is incorrect.)

     IF sy-subrc = 0.

       DELETE ct_ibsis[] WHERE bsis-zuonr = <ibsis>-bsis-zuonr.

     ENDIF.

   ENDLOOP.


fetching data from SET(GS01) but while activating i am getting error in another select query(The line structure of the table "GT_ZFINITEMCAT" is incorrect.),

please provide your valuable suggestion.


Regards,

Subhanshu Shrivastava

Hi Experts,

please check my code below

DATA: BEGIN OF ibsis OCCURS 100

         ebeln LIKE bseg-ebeln,   

         ebelp LIKE bseg-ebelp,   

         bsis LIKE bsis,          

         ldgrp TYPE fagl_ldgrp.   

DATA: END OF ibsis.              

TYPES : BEGIN OF TY_ZFINITEMCAT,

               pstyv TYPE vbap-pstyv,

             END OF TY_ZFINITEMCAT.

DATA : GT_ZFINITEMCAT TYPE STANDARD TABLE OF TY_ZFINITEMCAT.

FIELD-SYMBOLS : <fs_ZFINITEMCAT> TYPE TY_ZFINITEMCAT.


DATA: l_item_catecory TYPE pstyv.


SELECT VALFROM

          INTO TABLE GT_ZFINITEMCAT

          FROM SETLEAF

          WHERE SETNAME EQ 'ZFIN_ITEMCAT'.


LOOP AT ct_ibsis[] ASSIGNING <ibsis>.

"Check if we can find one item of the wrong category, if so then we remove the documents.

     SELECT SINGLE pstyv INTO l_item_catecory

       FROM vbap

       WHERE vbeln = <ibsis>-bsis-zuonr

         AND pstyv NOT IN GT_ZFINITEMCAT.  "getting error here (The line structure of the table "GT_ZFINITEMCAT" is incorrect.)

     IF sy-subrc = 0.

       DELETE ct_ibsis[] WHERE bsis-zuonr = <ibsis>-bsis-zuonr.

     ENDIF.

   ENDLOOP.


fetching data from SET(GS01) but while activating i am getting error in another select query(The line structure of the table "GT_ZFINITEMCAT" is incorrect.),

please provide your valuable suggestion.


Regards,

Subhanshu Shrivastava

4 REPLIES 4
Read only

Former Member
0 Likes
702

hi Subhanshu Shivastava,

    

          The internal table that u have mentioned in the select query inside the loop needs to be inside the breakets .

Replace the select Query mentioned below.

SELECT SINGLE pstyv INTO l_item_catecory

       FROM vbap

       WHERE vbeln = <ibsis>-bsis-zuonr

        AND pstyv NOT IN (GT_ZFINITEMCAT)

Kindly try this and meet your requirement.

Read only

Former Member
0 Likes
702

When using IN you must use a range table afterwards.

Try this :

DATA: BEGIN OF ibsis OCCURS 100,

         ebeln LIKE bseg-ebeln,  

         ebelp LIKE bseg-ebelp,  

         bsis LIKE bsis,         

         ldgrp TYPE fagl_ldgrp.  

DATA: END OF ibsis.             

DATA: gt_zfinitemcat type range of vbap-pstyv,

            

FIELD-SYMBOLS : <fs_ZFINITEMCAT&gt; TYPE any.


DATA: l_item_catecory TYPE pstyv.


SELECT VALFROM AS LOW

          INTO CORRESPONDING FIELDS OF TABLE GT_ZFINITEMCAT

          FROM SETLEAF

          WHERE SETNAME EQ 'ZFIN_ITEMCAT'.


LOOP AT GT_ZFINITEMCAT ASSIGNING <fs_ZFINITEMCAT>.

     <fs_ZFINITEMCAT>-SIGN       = 'I'.

     <fs_ZFINITEMCAT>-OPTION = 'EQ'.

ENDLOOP.


LOOP AT ct_ibsis[] ASSIGNING <ibsis&gt;.

"Check if we can find one item of the wrong category, if so then we remove the documents.

     SELECT SINGLE pstyv INTO l_item_catecory

       FROM vbap

       WHERE vbeln = <ibsis&gt;-bsis-zuonr

         AND pstyv NOT IN GT_ZFINITEMCAT.  "getting error here (The line structure of the table "GT_ZFINITEMCAT" is incorrect.)

     IF sy-subrc = 0.

       DELETE ct_ibsis[] WHERE bsis-zuonr = <ibsis&gt;-bsis-zuonr.

     ENDIF.

   ENDLOOP.

Read only

0 Likes
702

Hi Ziv Katz,

Yes got it, i tried with Ranges it is working.

Thanks,

Subhanshu Shrivastava

Read only

Former Member
0 Likes
702

I was glad to help you.

Reward points would be appreciated..