2016 Jan 06 4:13 PM
hi experts i have to write a prog with 3 tables and in 1st table I have to call 50 fields carrid connid fldate price......... till 50.
it takes lot of time to write each and every field.so, how to call those fields in sql statement any short cut or tips...
thank you in advance
2016 Jan 06 4:30 PM
It probably takes less time to type them in than asking the question here and waiting for an answer.
Rob
2016 Jan 06 4:30 PM
It probably takes less time to type them in than asking the question here and waiting for an answer.
Rob
2016 Jan 06 5:12 PM
it doesn't matter with no. if i have to write 250 fields then it takes time right.
ex:-
select carrid connid fldate price........250th field.
how to write above mentioned example of sql stat
2016 Jan 06 7:02 PM
If you have to manually put in more than ~20 fields then you're doing something wrong. Maybe the spec is wrong, maybe the requirement is silly. But chances are - it isn't necessary.
2016 Jan 07 2:54 AM
Yea i know that i dont have requirement with 50 fileds. If the requirement comes then what should i do.
2016 Jan 07 7:02 AM
What should you do? Question it strongly.
I've been doing ABAP since 1997. I've never encountered such a situation. So why worry about it?
2016 Jan 06 4:37 PM
Hi Akshay,
Interesting requirement you have, one way off the top of my head i can think possible doing this would be to dynamically generate parts of the sql statement using concatenation of strings.
To do this i would use the FM GET_COMPONENT_LIST which will return all the details about your ITAB. Then use a loop to loop through the result set and concatenate the field names into a string variable. Once you have done that you just use the string variable in place of the field names in the sql statement and SAP will run the query. I've done this before when i had to take dynamic list of conditions into consideration.
The code for the sql should look something like this Select (select_condition) FROM table_name ....
the ( ) are required for ABAP to treat the string as actual input into the sql. Below is an example i've done in a program before
TABLE = 'Z_SPL_AUDIT'.
CONCATENATE WHERE_CLS_1 '=' STATUS INTO WHERE_CLS_1 SEPARATED BY ' '.
CONCATENATE DATE_FIELD 'BETWEEN' DATE_LOW 'AND' DATE_HIGH INTO WHERE_CLS_2 SEPARATED BY ' '.
SELECT * FROM (TABLE) INTO CORRESPONDING FIELDS OF TABLE REPORT_T_FINAL
WHERE (WHERE_CLS_1) AND (WHERE_CLS_2).
The only unknown i have is i have not tried this dynamic approach in the actual Select portion only in the table and where clause but i would expect it to work still.
Hope this helps,
Geoffery
2016 Jan 06 4:41 PM
Hi,
Is this an interview question?
Why not just use select * into corresponding.
The structure of the internal table though has to have the 50 fields with the exact same name that it appears in database.
Kind regards, Rob Dielemans
2016 Jan 06 5:21 PM
this is not a interview question.
if i use select * into corresponding then performance drops.
Regards
Akshay Labhishetty
2016 Jan 06 5:25 PM
No - INTO CORRESPONDING won't give much of a performance hit. There are plenty of discussions on that topic in the ABAP space.
Rob
2016 Jan 06 7:04 PM
SELECT * may be a performance hit - especially with HANA. I've had massive gains in non-HANA and HANA systems by replacing * with a field list. However, as I said above, I can't think I've ever had to do more that ~20 fields. The fact is very very few realistic programs actually need more data than that.
SELECT INTO TABLE and SELECT INTO CORRESPONDING FIELDS OF TABLE are, as you say, performance-wise pretty much identical.
2016 Jan 06 5:01 PM
2016 Jan 06 5:16 PM
how to cop from se11.
should i copy each and every field. if so, for n example i have 250 fields then what should i do.
my requirement is show below as example.
ex:-
select carrid connid fldate price........250th field.
how to write above mentioned example of sql stat
2016 Jan 06 5:29 PM
Have you tried Ctrl + Y to copy the fields from SE11?
-Chandra
2016 Jan 06 5:32 PM
no. will it happen.
if so
i need particular fields then what shuld i do
2016 Jan 06 5:42 PM
Are you saying that you need the first 50 fields in the structure or 50 particular fields?
In any event, I think you have enough answers to do this.
Rob
2016 Jan 06 6:01 PM
I need solution for both the case.
i.e For 1st 50 and for particular 50.
2016 Jan 06 5:02 PM
Hi Akshay,
Try,
DATA: BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
LAEDA TYPE MARA-LAEDA,
END OF TY_MARA.
Just copy the fields to select Query.
Hope it helpful,
Regards,
Venkat.
2016 Jan 06 5:14 PM
bro i know that technique.
i want sol for the below shown example
ex:-
select carrid connid fldate price........250th field.
how to write above mentioned example of sql stat
2016 Jan 06 7:05 PM
If you cannot answer the question of why you need to have such a ridiculously high number of fields I will lock this thread.
You've already had a lot of guidance over what appears, frankly, to be quite a trivial issue.
2016 Jan 07 2:56 AM
My friend gave me a task to write a report of any table with all the fields present in it. So i am asking here.
2016 Jan 07 4:02 AM
Hi,
make the structure in your report in the way like Ventak suggested.
USE ALT+SHIFT+down arrow to select those fields..COPY them
paste after SELECT keyword that's all you can do (in the end).
thanks!!
2016 Jan 07 4:12 AM
2016 Jan 07 7:03 AM
In that case, there's been enough discussion of a trivial, hypothetical question, so I'm locking the thread.