cancel
Showing results for 
Search instead for 
Did you mean: 

DataType conversion

Former Member
0 Kudos
64

Hello:

I'm facing a problem about parameters into RFC/Selects. I learned here that when developing ABAP I should make sure to fill with zero's incomplete variables such as: '0000000029' instean of just '29'. In order to format it I could call:

call function 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = CLIENT_ID

IMPORTING

OUTPUT = CLIENT_ID.

Now I'm having a similar issue but I don't seem to figure it out the same way. I have:

FUNCTION Z_GET_REGION_DETAILS.

*"----


""Interfase local

*" IMPORTING

*" VALUE(CLIENT_ID) TYPE Z_CLIENT_ID OPTIONAL

*" EXPORTING

*" VALUE(COLONY) TYPE ADRC-LOCATION

*" VALUE(COUNTRY) TYPE T005T-LANDX

*"----


TYPES: BEGIN OF client_eq_type,

LAND1 TYPE KNA1-LAND1,

ADRNR TYPE KNA1-ADRNR,

LANDX TYPE T005T-LANDX,

LOCATION TYPE ADRC-LOCATION,

END OF client_eq_type .

DATA: client_eq TYPE client_eq_type.

CONSTANTS LANGUAGE LIKE T005T-SPRAS value 'S'.

And I get client_eq-ADRNR correctly. for instance it is a 29232. Now I go and use it to get data from another table:

SELECT SINGLE LOCATION

FROM ADRC

INTO client_eq

WHERE ADDRNUMBER = client_eq-ADRNR.

and I assign it as COLONY = client_eq-LOCATION.. However. this shows me nothing. I assume I should zero fill the remainning spaces for client_eq-ADRNR so I tried:

SELECT SINGLE LOCATION

FROM ADRC

INTO client_eq

WHERE ADDRNUMBER = '0000022539'.

But nothing. I also tried:

call function 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = client_eq-ADRNR

IMPORTING

OUTPUT = client_eq-ADRNR.

But none of this are working... any suggestions?

Thanks a lot!

Alejandro

Accepted Solutions (1)

Accepted Solutions (1)

former_member188685
Active Contributor
0 Kudos

SELECT SINGLE LOCATION

FROM ADRC

INTO <b>client_eq-location</b>

WHERE ADDRNUMBER = client_eq-ADRNR.

regards

vijay

Former Member
0 Kudos

Thanks Vijay... all that coding hasn't helped my eyes

Thanks

Alejandro

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos


* Get the actual colony:
 
SELECT SINGLE LOCATION
FROM ADRC
<b>INTO client_eq-LOCATION</b>
WHERE ADDRNUMBER = client_eq-ADRNR.
 
COLONY = client_eq-LOCATION.




Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You do realize that that answer was given 5 differnt times in this tread, right? We are all on top of it!!

Regards,

RIch Heilman

Former Member
0 Kudos

Yes I do, I really appreciate... I do realize that it's all due to my inexperience on ABAP =(

Thank you guys! it's a record!

Alejandro

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Since you want to populate the COLONY...

You can do this way too...

SELECT SINGLE LOCATION

FROM ADRC

INTO <b>COLONY</b>

WHERE ADDRNUMBER = client_eq-ADRNR.

Former Member
0 Kudos

Hi,

In Your code : Replace client_eq with COLONY

SELECT SINGLE LOCATION

FROM ADRC

INTO <b>COLONY</b> WHERE ADDRNUMBER = client_eq-ADRNR.

This will popukate Export parameter of your function module.

Lanka

suresh_datti
Active Contributor
0 Kudos

just a small correction..

SELECT SINGLE LOCATION

FROM ADRC

INTO <b>client_eq-location</b>

WHERE ADDRNUMBER = client_eq-ADRNR.

Regards,

Suresh Datti

Former Member
0 Kudos

Sorry about that. This is my complete code:


FUNCTION Z_GET_REGION_DETAILS.
*"----------------------------------------------------------------------
*"*"Interfase local
*"  IMPORTING
*"     VALUE(CLIENT_ID) TYPE  Z_CLIENT_ID OPTIONAL
*"  EXPORTING
*"     VALUE(COLONY) TYPE  AD_LCTN
*"     VALUE(COUNTRY) TYPE  T005T-LANDX
*"----------------------------------------------------------------------

TYPES: BEGIN OF client_eq_type,
          LAND1  TYPE KNA1-LAND1,
          ADRNR TYPE KNA1-ADRNR,
          LANDX TYPE T005T-LANDX,
          LOCATION TYPE ADRC-LOCATION,
      END OF client_eq_type .

DATA: client_eq TYPE  client_eq_type.

CONSTANTS LANGUAGE LIKE T005T-SPRAS value 'S'.

*Transform input data
call function 'CONVERSION_EXIT_ALPHA_INPUT'
     EXPORTING
      INPUT = CLIENT_ID
     IMPORTING
      OUTPUT = CLIENT_ID.
* Get the customer:
SELECT SINGLE LAND1 ADRNR
FROM KNA1
INTO client_eq
WHERE KUNNR = CLIENT_ID.

* Get country and Colonycode:

* I don't want the code, I need textual representation:
* GET actual country
SELECT SINGLE LANDX
FROM T005T
INTO client_eq
WHERE LAND1 = client_eq-LAND1 AND SPRAS = LANGUAGE.

COUNTRY = client_eq-LAND1.
COLONY = client_eq-ADRNR.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = client_eq-ADRNR
IMPORTING
OUTPUT = client_eq-ADRNR.
* Get the actual colony:

SELECT SINGLE LOCATION
FROM ADRC
INTO COLONY
WHERE ADDRNUMBER = client_eq-ADRNR.

COLONY = client_eq-LOCATION.


ENDFUNCTION.

Former Member
0 Kudos

Hi,

Check your structures here..

You have 4 fields in your internla table structure,but you are selecting only location.

Change your select...which i am mentioning in BOLD.

TYPES: BEGIN OF client_eq_type,

LAND1 TYPE KNA1-LAND1,

ADRNR TYPE KNA1-ADRNR,

LANDX TYPE T005T-LANDX,

LOCATION TYPE ADRC-LOCATION,

END OF client_eq_type .

DATA: client_eq TYPE client_eq_type.

SELECT SINGLE LOCATION

FROM ADRC

INTO <b>corresponding fields of table</b> client_eq

WHERE ADDRNUMBER = client_eq-ADRNR.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Please post the <b>complete</b> code. So I can see were you are going wrong.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I see something wrong already. You will want to put the location field into the location field of client_eq.




SELECT SINGLE LOCATION
      FROM ADRC
          INTO <b>client_eq-location</b>
                 WHERE ADDRNUMBER = client_eq-ADRNR.


Regards,

Rich HEilman