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 constant from Transp. Table

Former Member
0 Likes
1,578

Hello

I would like to make the following select from Transp. Table :

Select F1 F2 'ABC' AS SOURCE

FROM Transp. Table

F1, F2 - fields of the table , 'ABC' is a char constant , the same for all records of the table

I dont want to run Loop-End loop and populate the constant there.

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
795

Hello,

You can use MODIFY ... TRANSPORTING statement for this. No need to use LOOP...ENDLOOP.

TYPES:
BEGIN OF ty,
  bukrs TYPE bukrs,
  text  TYPE string,
END OF ty.

DATA:
      itab TYPE STANDARD TABLE OF ty,
      wa   TYPE ty.

SELECT bukrs FROM t001 INTO TABLE itab.
IF sy-subrc = 0.
  wa-text = 'Test Modify'.
  MODIFY itab FROM wa TRANSPORTING text WHERE bukrs IS NOT INITIAL.
ENDIF.

LOOP AT itab INTO wa.
  WRITE : / wa-bukrs, 10 wa-text.
ENDLOOP.

Hope i am clear.

BR,

Suhas

5 REPLIES 5
Read only

Former Member
0 Likes
795

Hi,

Select F1 F2 'ABC' AS SOURCE

FROM Transp. Table

Your saying that ABC is same for all records of the table.So it must be one of the field of the table.

SELECT F1 F2 <your field>

From TABLE

WHERE <your field> = 'ABC'.

Regards,

Subhashini

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
796

Hello,

You can use MODIFY ... TRANSPORTING statement for this. No need to use LOOP...ENDLOOP.

TYPES:
BEGIN OF ty,
  bukrs TYPE bukrs,
  text  TYPE string,
END OF ty.

DATA:
      itab TYPE STANDARD TABLE OF ty,
      wa   TYPE ty.

SELECT bukrs FROM t001 INTO TABLE itab.
IF sy-subrc = 0.
  wa-text = 'Test Modify'.
  MODIFY itab FROM wa TRANSPORTING text WHERE bukrs IS NOT INITIAL.
ENDIF.

LOOP AT itab INTO wa.
  WRITE : / wa-bukrs, 10 wa-text.
ENDLOOP.

Hope i am clear.

BR,

Suhas

Read only

Former Member
0 Likes
795

thanks

constant ABC isnt a part of the table. Its not a field of the table.

I need it to know where the data was derived from.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
795

Hello,

If i understand correctly ABC is an identifier of the data source. You want this identifier to be able to identify from which table the data has come.

I donot think you can do this w/o defining it as a table field.

BR,

Suhas

Read only

Former Member
0 Likes
795

Hi,

I will suggest you to fill the dummy column right after the query through MODIFY statement as descirbed above.

And then if you get more data into the same tab using SELECT.. APPENDING... then again u can fill your dummy column through MODIFY.

Only additional processing time will be the MODIFY statements, and that wont be too much and your purpose will be served of identifying the source too..

Revert if I havent been able to clarify myself.