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 statement not working on table ADRC???

Former Member
0 Likes
2,837

Can anyone tell me why this works for the first table and not he second?

Ok when I use the SELECT SINGLE statement on table T005X it works

I set everthing up like so

DATA: TEST_VAR1(2) TYPE C VALUE 'US'.

DATA: wa_t005x type t005x.

select single * from t005x into wa_t005x where land = TEST_VAR1.

and all the fields in wa_t005x have a value.

But.....when I do the same thing against table ADRC

DATA: TEST_VAR2(5) TYPE C VALUE 36705.

DATA: WA_ADRC TYPE ADRC.

Select single * from ADRC into WA_ADRC where ADDRNUMBER = TEST_VAR2.

I don't pull any data to the WA_ADRC fields

any thoughts?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,381

Please pass leading zero's in where condition while selecting ADRC.

19 REPLIES 19
Read only

Former Member
0 Likes
2,382

Please pass leading zero's in where condition while selecting ADRC.

Read only

0 Likes
2,381

Ok First i checked table ADRC-ADDRNUMBER's length and found it to be 10

the only way I know how to do that is to change to this

DATA: TEST_VAR2 TYPE n length 10 VALUE 36705.

So i tried that and go this output for TEST_VAR2 0000036705

but still nothing in WA_ADRC-ADDRNUIMBER is still blank

i tried with N LENGTH 10 and C LENGTH 10.

Is there another way to do this?

Read only

0 Likes
2,381

In order to get the leading zeroes, like indicated rightfully in the first reply, do the following:

 
DATA: TEST_VAR2(10) TYPE C VALUE 36705.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input        = TEST_VAR2
  IMPORTING
   output        = TEST_VAR2.

Kind regards,

Robert

Read only

0 Likes
2,381

Same thing output for TEST_VAR2 is 0000036705

and nothing for ADDRNUMBER

I'm going to post the code just incase someone see's something I don't (i'm not getting any errors)

*************************TABLE ADRC*******************************************

DATA: TEST_VAR2(10) TYPE C VALUE 36705.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = TEST_VAR2

IMPORTING

output = TEST_VAR2.

DATA: WA_ADRC TYPE ADRC.

Select single * from ADRC into WA_ADRC where ADDRNUMBER = TEST_VAR2.

WRITE:/ 'THIS IS WHAT IS STORED IN TEST_VAR RIGHT NOW: ', TEST_VAR2.

WRITE:/ 'OK LETS HOPE THIS IS THE SAME FOR ADDRNUMBER: ', WA_ADRC-ADDRNUMBER.

*****************************TABLE T005X*****************************************

DATA: TEST_VAR1(2) TYPE C VALUE 'US'.

DATA: wa_t005x type t005x.

select single * from T005X into WA_T005X where LAND = TEST_VAR1.

WRITE:/ 'OK LETS TRY DIFFERENT SET THIS IS COUNTRY: ', TEST_VAR1.

WRITE:/ 'AND THIS IS WA_T005X-LAND I HOPE: ', WA_T005X-LAND.

WRITE:/ 'THIS IS A TEST TO SEE IF I GOT THE WHOLE TABLE FROM WA_T005X'.

WRITE:/ 'OK THIS IS THE DATE FORMAT CHAR: ', WA_T005X-DATFM.

WRITE:/ 'AND THE TIME FORMATE: ', WA_T005X-TIMEFM.

WRITE:/ 'AND THE DECIMAL NOTATION: ', WA_T005X-XDEZP.

WRITE:/ 'AND THE CLIENT: ', WA_T005X-MANDT.

Read only

0 Likes
2,381

I have tested and it works as we expected.

see the source code :

tables : adrc.

data: wa_adrc like adrc,

test_var2(10) type c.

start-of-selection.

test_var2 = '22349'.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = test_var2

importing

output = test_var2.

select single * from adrc into wa_adrc

where addrnumber = test_var2.

if sy-subrc eq 0.

write:/ wa_adrc-addrnumber.

endif.

Read only

0 Likes
2,381

Are you sure the number is actually 36705? Check it on SE16 for ADRC? Maybe you are looking in a different client??

Read only

0 Likes
2,381

Yep this is copied and pasted right from SE16 36705 just to be sure

I tried your code too Seshu and it still didn't give me a value maybe something else is wrong I don't know any ideas?

Read only

0 Likes
2,381

did you try with:

DATA: TEST_VAR2(10) TYPE n VALUE 36705.

Type = N not C.

Read only

0 Likes
2,381

I copied Seshu's program and tested it with a value in our system and it works fine, so there must either be a problem with your data or somewhere in your program.

I would recommend you doing the same.

Kind regards,

Robert

Read only

0 Likes
2,381

I have tried your own code in my system, with a different addrnumber, and it works.

Have you tried debugging it? Step through and watch if the variable is changed as you expect it to.

Read only

0 Likes
2,381

hi,

declare your field like

DATA: TEST_VAR2 like adrc-ADDRNUMBER VALUE 36705.

and use CONVERSION_EXIT_ALPHA_INPUT for TEST_VAR2.

regards

Ganesh Reddy

Edited by: Ganesh Reddy on Feb 17, 2011 10:15 AM

Read only

0 Likes
2,381

PLEASE DECLARE TEST_VAR(2) TYPE (TABLE-FIELDNAME) OR (DATAELEMENT) INSTEAD OF CHAR 10

Read only

former_member186741
Active Contributor
0 Likes
2,381

you can also do it like this:

DATA: TEST_VAR2(10) TYPE n VALUE 36705.

DATA: WA_ADRC TYPE ADRC.

Select single * from ADRC into WA_ADRC

where ADDRNUMBER = TEST_VAR2.

write:/ sy-dbcnt.

Read only

Former Member
0 Likes
2,381

Hi..

Conversion routine is there for this field ADDRNUMBER domain AD_ADDRNUM.

Use FM's CONVERSION_EXIT_ALPHA_INPUT

CONVERSION_EXIT_ALPHA_OUTPUT

to convert the value and then pass.

regards,

Lokesh

Read only

Former Member
0 Likes
2,381

Hi

This is working for me


DATA: var2(10) TYPE c VALUE 36705.

DATA: wa_adrc TYPE adrc.

UNPACK var2 TO var2.
SELECT SINGLE * FROM adrc INTO wa_adrc WHERE addrnumber = var2.
WRITE: wa_adrc.

Did you check if this 36705 address number exist?

Read only

Former Member
0 Likes
2,381

DATA: TEST_VAR2(10) TYPE C VALUE '0000036705'.
DATA: WA_ADRC TYPE ADRC.



Select single * from ADRC into WA_ADRC where ADDRNUMBER = TEST_VAR2.

Read only

Former Member
0 Likes
2,381

Try following code it works perfectly.


DATA: TEST_VAR2(10) TYPE C VALUE '0000036705'.
DATA: WA_ADRC TYPE ADRC.



Select single * from ADRC into WA_ADRC where ADDRNUMBER = TEST_VAR2.

Read only

Former Member
0 Likes
2,381

first, use SE11 or SE16 to see if your address number exists in ADRC....simplest way to find out why your program didn't work, I think.

Read only

Former Member
0 Likes
2,381

Sorry everyone all the code is working fine now I was having an issue with my sandbox

I have all the code from this thread pasted into my program and everyone's is working correctly now

including my original setup

sorry and thanks for everyone's help and quick replies