‎2013 Mar 12 6:18 AM
Hi,
I can write query like this i SQL.
SELECT VBELN, '1' AS Flag FROM VBAK WHERE.......
How can i do this in ABAP?
‎2013 Mar 12 8:39 AM
Hi Sathya,
I doubt if there is a syntax that allows to put default value in column from select statement.
Anyhow you can get same results by few ABAP commands, like example below:
DATA ls_vbak type vbak.
DATA lt_vbak type table of vbak.
ls_vbak-vbtyp = '1'. " Constant defined
SELECT VBELN FROM VBAK INTO TABLE lt_vbak WHERE ...
MODIFY lt_vbak from ls_vbak transporting vbtyp WHERE vbtyp IS INITIAL.
Regards,
Adam
‎2013 Mar 12 9:16 AM
Hi Satya,
You can write in abap as follows:
SELECT VBELN
from vbak
into table t_vbak
where vbeln eq '1'.
Regards,
Vineesh.
‎2013 Mar 12 9:29 AM
Hi Sathya,
this is not possible by only using the SELECT statement. This is what you can do:
1) Use the approach mentioned by Adam
2) Define a loop after you executed the SELECT which may look like this:
FIELD-SYMBOL <f_s_yourTable> TYPE <yourTable>.
LOOP AT <yourTable> ASSIGNING <f_s_yourTable>.
<f_s_yourTable>-yourStaticField = '1'.
ENDLOOP.
This is very fast and therefore should not lead to any performance issues. This is also discussed here: http://scn.sap.com/thread/3229304
BR, Jascha
‎2013 Mar 12 9:45 AM
Hi Sathya,
You can write the query like that when the case occured as your internal table or work area structure field is different and your dictionary table field is differnt but with the same data type.
please find the delow example code.
TYPES : BEGIN OF TY_MARA,
MAT TYPE MATNR,
END OF TY_MARA.
DATA : WA_MARA TYPE TY_MARA.
SELECT SINGLE MAT AS MATNR
FROM MARA
INTO WA_MARA
WHERE ...................
Thanks
Mani
‎2013 Mar 12 10:44 AM
‎2013 Mar 22 1:03 PM
Hi Sathya,
I think you are new in SAP ABAP (i think so ) its a basic question any way please refer the below link it explain's how to use the SELECT statement in abap.
http://help.sap.com/erp2005_ehp_04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm
Please search in scn before posting (Otherwise Moderator will lock the Discussion ).
Regards
Mahesh .
‎2013 Mar 22 1:17 PM
Hi Sathya,
you can do this with ABAP Open SQL.
But you can use the following solution:
Keep FLAG column in our IT_VBAK as the last column.
Do your selection normally, without using this flag.
Right after select, update your IT_VBAK.
wa_vbak-flag = '1'.
modify it_vbak from wa_vbak transporting flg
where flag is initial.
Regards,
Frisoni
‎2016 Jun 30 12:18 PM