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

substring in sql statment

eyup_aksoy
Explorer
0 Likes
447

Hi everybody,

How can i work it;

s_mjahr(year char4) is select-options . 

plaf-psttr is date(dats) type

  select mara~mtart mara~matkl plaf~matnr plaf~plwrk plaf~verid

  into  (gt_out-mtart, gt_out-matkl, gt_out-matnr, gt_out-plwrk,

         gt_out-verid)

  from plaf inner join mara on ( plaf~matnr = mara~matnr )

  where plaf~matnr      in s_matnr

    and plaf~plwrk      in s_werks

    and mara~mtart      in s_mtart

*    and plaf~psttr+0(4) in s_mjahr   "--> not working

      .

append gt_out.

endselect.

thank.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
406

Hi,

I don't think you could make it work in the SQL statement.

What you could do is:

Add field PSTTR to the structure of GT_OUT and don't append the line if it does not match your condicition.

Something like this:

  SELECT mara~mtart mara~matkl plaf~matnr plaf~plwrk plaf~verid plaf~psttr

   INTO  (gt_out-mtart, gt_out-matkl, gt_out-matnr, gt_out-plwrk, gt_out-verid, gt_out-psttr)

   FROM plaf INNER JOIN mara ON ( plaf~matnr = mara~matnr )

   WHERE plaf~matnr      IN s_matnr

     AND plaf~plwrk      IN s_werks

     AND mara~mtart      IN s_mtart       .

    IF gt_out-psttr(4) IN s_mjahr.

      APPEND gt_out.

    ENDIF.

  ENDSELECT.

2 REPLIES 2
Read only

Former Member
0 Likes
407

Hi,

I don't think you could make it work in the SQL statement.

What you could do is:

Add field PSTTR to the structure of GT_OUT and don't append the line if it does not match your condicition.

Something like this:

  SELECT mara~mtart mara~matkl plaf~matnr plaf~plwrk plaf~verid plaf~psttr

   INTO  (gt_out-mtart, gt_out-matkl, gt_out-matnr, gt_out-plwrk, gt_out-verid, gt_out-psttr)

   FROM plaf INNER JOIN mara ON ( plaf~matnr = mara~matnr )

   WHERE plaf~matnr      IN s_matnr

     AND plaf~plwrk      IN s_werks

     AND mara~mtart      IN s_mtart       .

    IF gt_out-psttr(4) IN s_mjahr.

      APPEND gt_out.

    ENDIF.

  ENDSELECT.

Read only

Former Member
0 Likes
406

Hi,

Try this, it will work,

assign the values of your select-option into a range table like,

SIGN = 'I'

OPTION = 'CP' 'Contains Pattern

LOW & HIGH from your select-option embedded with a * at the last (like if the year is 1990 append as 1990*)

And and in the select querry modify the statment

and plaf~psttr+0(4) in s_mjahr   "--> not working

AS

and plaf~psttr in r_mjahr(range table) 

Hope this helps