cancel
Showing results for 
Search instead for 
Did you mean: 

SOURCE_PACKAGE - Read Operation

Former Member
0 Kudos

hello,

i have a question..

how can i read a single data from a SOURCE_PACKAGE.


SELECT SINGLE *
       FROM SOURCE_PACKAGE
       INTO ls_before_image
       WHERE vbeln    EQ  <source_fields>-vbeln
       AND      posnr    EQ <source_fields>-posnr

IF sy-subrc = 0.
  ...

But it dont work... how can i do that??? and how can i delete a single data from SOURCE_PACKAGE with keys.

Actually i do it like


 LOOP AT SOURCE_PACKAGE INTO ls_before_image
    WHERE vbeln    EQ <source_fields>-vbeln
    AND posnr    EQ <source_fields>-posnr
 ENDLOOP.

IF sy-subrc = 0.
  ...

Is this the only way to do that?

regards sunny

Edited by: sunnyfriday on May 6, 2009 11:43 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

shanthi_bhaskar
Active Contributor
0 Kudos

hey sunny second one is the standrad way...

like this..


 LOOP AT SOURCE_PACKAGE INTO <FS>

assign <fs> to source_package.
 ENDLOOP.

Former Member
0 Kudos

hi,

if the data is found... then it should break the loop.

and i need to operate with <fs>

Like.

1. Read dataset with key (key1 key2) from SOURCE_PACKAGE into local_var.

2. operate with local_var.

3. delete local_var from the SOURCE_PACKAGE.

mansi_dandavate
Active Contributor
0 Kudos

Hi Sunny,

WHy dont you try the statement

delete source_package where key1 = .... and key2 = ...

Regards,

Mansi

Former Member
0 Kudos

hi,

i do it like that. Is that ok?

         
  LOOP AT SOURCE_PACKAGE INTO ls_before_image
            WHERE vbeln    EQ  <source_fields>-vbeln
                 AND posnr    EQ <source_fields>-posnr
          
       If sy-subrc = 0
              * operate with ls_before_image
     
          delete source_package where vbeln = <source_fields>-vbeln  and posnr = <source_fields>-posnr.
         exit.       
      endif

    ENDLOOP.

shanthi_bhaskar
Active Contributor
0 Kudos
 
LOOP AT SOURCE_PACKAGE INTO <source_fields>-
            WHERE vbeln    EQ  <source_fields>-vbeln
                 AND posnr    EQ <source_fields>-posnr
          
       If sy-subrc = 0
              * operate with ls_before_image
     
          delete source_package where vbeln = <source_fields>-vbeln  and posnr = <source_fields>-posnr.
         exit.       
      endif
    assign <source_fields> to source_package.
    ENDLOOP.

use this

mansi_dandavate
Active Contributor
0 Kudos

LOOP AT SOURCE_PACKAGE INTO ls_before_image

WHERE vbeln EQ <source_fields>-vbeln

AND posnr EQ <source_fields>-posnr

If sy-subrc = 0

  • operate with ls_before_image

delete source_package.

  • where vbeln = <source_fields>-vbeln and posnr = <source_fields>-posnr. ( no need to chk this again)

exit.

endif

ENDLOOP.

You want to delete all the records in source_package which meet the conditions??

Then dont use exit in the loop.

Because then it will delete the first record and exit from the loop.

Regards,

Mansi