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 query

former_member515329
Participant
0 Likes
1,335

SELECT matnr

VKORG

TRVOG

AUDAT

VTWEG

SPART

AUART

KUNNR

VKBUR

VKGRP

BSTNK

ERNAM

VBELN

POSNR

FROM vapma INTO

CORRESPONDING FIELDS of TABLE i_vapma

  • WHERE matnr = wa_input_bdc-matnr

WHERE matnr = '10290554'

  • AND vkorg = p_vkorg

AND vkorg = '0300'

  • AND trvog = v_trvog

AND trvog = '4'

  • AND vtweg = p_vtweg

AND vtweg = '90'

  • AND spart = p_spart.

AND spart = '67'.

above select query is not working....is any syntax error in this...

my internal table declared as :

data : begin of i_vapma occurs 0,

matnr like vapma-matnr,

VKORG like vapma-vkorg,

TRVOG like vapma-trvog,

AUDAT like vapma-audat,

VTWEG like vapma-vtweg,

SPART like vapma-spart,

AUART like vapma-auart,

KUNNR like vapma-kunnr,

VKBUR like vapma-vkbur,

VKGRP like vapma-vkgrp,

BSTNK like vapma-bstnk,

ERNAM like vapma-ernam,

VBELN like vapma-vbeln,

POSNR like vapma-posnr,

  • kunnr like vapma-kunnr,

end of i_vapma.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,272

Hi Ravi,

Check this once...!

In you Select Statement "Remove Corresponding Fields of (Not necessary Since Same Struce as Internal Table)


DATA : P_MATNR TYPE MARA-MATNR.

P_MATNR = '10290554'.
*Debug from here and see p_matnr what happens after the function module
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT  = P_MATNR
  IMPORTING
    OUTPUT = P_MATNR.

SELECT MATNR
VKORG
TRVOG
AUDAT
VTWEG
SPART
AUART
KUNNR
VKBUR
VKGRP
BSTNK
ERNAM
VBELN
POSNR
FROM VAPMA INTO
TABLE I_VAPMA "Remove Corresponding Fields of
WHERE MATNR = '000000000010290554' "Pass the leading 0's Total should be 18 chars Or Use P_MATNR
*WHERE MATNR = P_MATNR
AND VKORG = '0300'
AND TRVOG = '4'
AND VTWEG = '90'
AND SPART = '67'.

Thanks & regards,

Dileep .C

11 REPLIES 11
Read only

Former Member
0 Likes
1,272

Hi Ravi

For performance sake, remove CORRESPONDING FIELDS OF from your select query. Coming to your ques, please let us know what is the error you are getting? Incase it is not selecting any values into i_vapma itab, goto the database table VAPMA in se11 and try executing it with the values you are passing in the WHERE clause. Check if the values actually exist.

Do let me know incase the problem persists.

Hope this helps.

Harsh

Read only

0 Likes
1,272

i have removed corresponding fields...i have checked in se11 it has around 200 entries...i m getting no error..but when i goto debug mode..after select query sy-subrc is 4 ...and no values r there in i_vapma table

Read only

Former Member
0 Likes
1,272

ur query looks ok.,.. and had it been a sytax error u cud have got an error while activating it.

any ways....

i guess ur select statement is not giving back any value.. if so then... pass the same values to the se16 in the table n see u have entries corresponding to it or not..

and i guess the values u are passing in where can be wrong.. loke '0300' in place of '300' etc...

and DO NOT USE " into correspoding fields" .. directly use "into table"

and see... actually few fields have converstion routine to add the starting zeros and few have not,,,, so please check accordingly..

Edited by: soumya prakash mishra on Jun 21, 2009 3:37 PM

Read only

Former Member
0 Likes
1,272

Hi,

Please check the value which you have passed in where clause:

Befor passing MATNR value use FM 'Conversion_exit' to get the leading 0 for the material number, similary check for the remaining feilds in where clause. Check the conversion routine for every field.

Hope this may be useful.

Regards,

Prashant

Read only

Former Member
0 Likes
1,272

Ravi,

When you pass values directly, you need to pass the exact size of the field. For Ex: you need to append few leading zeroes as I can see only 8 digits in ur matnr. Similarly check for other fields also from your WHERE clause and then try again.

Since ur have the field selection in the same order of your internal table, you dont use INTO CORRESPONDING.

Thanks

Kiran

Read only

Former Member
0 Likes
1,273

Hi Ravi,

Check this once...!

In you Select Statement "Remove Corresponding Fields of (Not necessary Since Same Struce as Internal Table)


DATA : P_MATNR TYPE MARA-MATNR.

P_MATNR = '10290554'.
*Debug from here and see p_matnr what happens after the function module
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT  = P_MATNR
  IMPORTING
    OUTPUT = P_MATNR.

SELECT MATNR
VKORG
TRVOG
AUDAT
VTWEG
SPART
AUART
KUNNR
VKBUR
VKGRP
BSTNK
ERNAM
VBELN
POSNR
FROM VAPMA INTO
TABLE I_VAPMA "Remove Corresponding Fields of
WHERE MATNR = '000000000010290554' "Pass the leading 0's Total should be 18 chars Or Use P_MATNR
*WHERE MATNR = P_MATNR
AND VKORG = '0300'
AND TRVOG = '4'
AND VTWEG = '90'
AND SPART = '67'.

Thanks & regards,

Dileep .C

Read only

0 Likes
1,272

see...i have chnaged my select query...but don't know why it is not picking exact values from table vapma...pls help

*--FM for Conversion Exit for Material Number

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = wa_input_bdc-matnr

IMPORTING

output = v_matnr1.

*--FM for Conversion Exit for SoldTO

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wa_input_bdc-soldto

IMPORTING

OUTPUT = v_soldto1.

concatenate sy-datum4(2) sy-datum6(2) sy-datum+0(4) into v_dat_date

separated by '/'.

SELECT matnr FROM vapma INTO TABLE i_vapma

WHERE matnr = v_matnr1

AND vkorg = p_vkorg

AND trvog = v_trvog

AND vtweg = p_vtweg

AND spart = p_spart

AND ( auart = 'YDOL' OR auart = 'YDCL'

OR auart = 'YDSC' OR auart = 'YDPC' )

AND kunnr = v_soldto1

AND datab <= '06/24/2009' "v_dat_date

AND datbi >= '06/24/2009'."v_dat_date.

Read only

0 Likes
1,272

I m having doubt in this last 2 fields..

AND datab <= '06/24/2009' "v_dat_date

AND datbi >= '06/24/2009'."v_dat_date.

if i comment these..then i m getting the correct ouput...is this correct way of giving the date..

Read only

0 Likes
1,272

Hi,

AND datab <= '20090624' "v_dat_date

AND datbi >= '20090624'."v_dat_date.

Regards,

Kumar Bandanadham

Read only

0 Likes
1,272

Hi,

When you are not sure as to how you pass your date format, do a debugging on your sy-datum and check the format.

It should have been

AND datab <= '20090624' . "v_dat_date

AND datbi >= '20090624'. "v_dat_date.

Read only

0 Likes
1,272

Hi,

use this select query....

SELECT mandt 
matnr 
FROM vapma 
INTO TABLE i_vapma
WHERE matnr = v_matnr1
AND vkorg = p_vkorg
AND trvog = v_trvog
AND vtweg = p_vtweg
AND spart = p_spart
AND ( auart = 'YDOL' OR auart = 'YDCL'
OR auart = 'YDSC' OR auart = 'YDPC' )
AND kunnr = v_soldto1
AND datab <= sy-datum "v_dat_date
AND datbi >= sy-datum. "v_dat_date.

Regards,

Siddarth