2013 Nov 07 11:30 PM
I'm learning to work with ABAP-SAP and I want to know how can I replace this obsolete code:
SELECT SINGLE * FROM SADR
WHERE ADRNR EQ T001-ADRNR
I know SADR table is obsolet but I don´t know where do I start to replace this code.
Please somebody help me.
Thanks in advanced.
Message was edited by: Matthew Billingham - added meaningful subject.
I'm learning to work with ABAP-SAP and I want to know how can I replace this obsolete code:
SELECT SINGLE * FROM SADR
WHERE ADRNR EQ T001-ADRNR
I know SADR table is obsolet but I don´t know where do I start to replace this code.
Please somebody help me.
Thanks in advanced.
Message was edited by: Matthew Billingham - added meaningful subject.
2013 Nov 07 11:49 PM
Hey mate,
Easy fix, just do the following,
SELECT * UP TO 1 ROWS
INTO lv_address
FROM adrc
WHERE addrnumber EQ lv_t001-adrnr
AND date_from LE sy-datum
AND date_to GE sy-datum.
ENDSELECT.
Make sure when doing a select statement always use the SELECT / ENDSELECT and UP TO 1 ROWS when you are not selecting the whole key of a table. Just using SELECT SINGLE will sometimes get you the wrong result.
Cheers
Shaun
2013 Nov 08 12:31 AM
Hey, thanks for the response, but, what if I use call function
WK_ADDR_SEL-ADDRNUMBER = TVBUR-ADRNR.
CALL FUNCTION 'ADDR_GET'
EXPORTING
ADDRESS_SELECTION = WK_ADDR_SEL
IMPORTING
SADR = SADR
EXCEPTIONS
PARAMETER_ERROR = 1
ADDRESS_NOT_EXIST = 2
VERSION_NOT_EXIST = 3
INTERNAL_ERROR = 4
OTHERS = 5.
what´s your opinion.
thank u.
2013 Nov 08 3:47 AM
Hi,
If you have a FM then you should go with it. But its all based on your requirement.
I checked the the above FM and its retrieving the value from SADR.
All you need to do is, declare an internal table of type sadr and use it in the importing parameter.
Regards.
2013 Nov 08 4:10 AM
Hi alejandro Alvarez ,
Try like this
DATA : wa_adrc TYPE adrc.
SELECT SINGLE * FROM adrc
INTO wa_adrc
WHERE addrnumber EQ wa_t001-adrnr
AND date_from LE sy-datum
AND date_to GE sy-datum.
If your requirement fulfills with Function Module ADDR_GET
then you can proceed with that......
2013 Nov 08 6:15 AM
Shaun Bradridge wrote:
Hey mate,
Easy fix, just do the following,
SELECT * UP TO 1 ROWS
INTO lv_address
FROM adrc
WHERE addrnumber EQ lv_t001-adrnr
AND date_from LE sy-datum
AND date_to GE sy-datum.
ENDSELECT.
Make sure when doing a select statement always use the SELECT / ENDSELECT and UP TO 1 ROWS when you are not selecting the whole key of a table. Just using SELECT SINGLE will sometimes get you the wrong result.
Cheers
Shaun
Wrong.
2013 Nov 11 11:40 PM
Thanks for the kind words Matthew really helpful pointing out problems without giving resolution, but you are right, when you look at the sql statements that are actually the same when you use Select single or UP to 1 rows. It is just a developers best practice to use UP to 1 rows when not selecting from the whole key.
Shaun
Only
2013 Nov 12 6:57 AM
I thought highlighting the incorrect statement was sufficient explanation.
"Just using SELECT SINGLE will sometimes get you the wrong result." No, it won't.
Is that enough?
It is not, in my view, developers best practice to use up to 1 rows when not selecting the whole key. It makes the code less readily understandable, so I think it is bad programming practice. SELECT SINGLE as an existence check, or when I'm only wanting results from part of the key, or where the table has a unique index that I'm actually using is perfectly acceptable. The only reason, in my view, that the SELECT ... UP TO 1 ROWS came up was because SLIN at one time objected to a SELECT SINGLEs where the full primary key isn't specified. Unfortunately many programmers (and QA departments) take SLIN as law, rather than as guidance - resulting in more complex code with all the consequences of that.
On this site, there are many myths that are perpetuated. If someone gives incorrect technical information I will point it out. Rejecting the post is an option, but I feel that closes discussion.
2013 Nov 13 5:09 PM
Hi Ramesh I mean , if I want to use a function module, what FM would I use, because I have seen several options about that.
Can you tell me.
Thanks in advanced
2013 Nov 08 12:01 AM
DATA lw_sadr TYPE sadr.
DATA lw_t001 TYPE t0001.
* First fetch your lw_t001 variable
SELECT SINGLE *
INTO lw_sadr
FROM sadr
WHERE adrnr EQ lw_t001-adrnr.
2013 Nov 08 3:41 AM
SELECT SINGLE * FROM SADR
WHERE ADRNR EQ T001-ADRNR
In this query where you are storing your result. You need to create a workarea of type SADR and store your result into that.
2013 Nov 08 3:44 AM
Hi , EASY ANSWER
data lv_var type sadr .
SELECT SINGLE * FROM SADR
Into lv_var
WHERE ADRNR EQ T001-ADRNR
2013 Nov 08 4:17 AM
2013 Nov 08 3:45 AM
HI alejandro,
ADRC is the central address table. It is has any address that you enter in SAP.
SADR is no longer used, it was the table prior to ADRC.
Check OSS note 85676 - Customer objects: conversion of SADR addresses.
You can code it like :
Select single *
from adrc
into internal_table
where condition.
Regards,
sivaganesh
2013 Nov 08 3:46 AM
Hi Alvarez,
ADRC is the central address table. U can use this table as a replacement of SADR table.. and use ADDRNUMBER (address no) fied in where condition.
One more thing, create a work area (type ADRC) to hold the fetched values..
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |