Insert entries in ABAP QUERY
I have an abap query with tables VBRK and VBRP.
The result is all of the items of VBRP.
I want to join this with the item texts, with function READ_TEXT.
How can I do that?
Ivan Shadrin replied
In fact, there is no good way to display a long string in an ALV cell.
But there are two most common workarounds.
1. I have already described it in my previous reply. You can split the text into few additional text columns. But, of course, this solution is not elegant.
2. You can implement a drill-down for the text field. By default you can display first 100 characters in your text field (LTEXT). In most cases it is enougth.
But if the text is longer, user can use double-click on that cell to display entire text.
I have discovered that it is possible in SAP Query.
2.1. Create an ABAP report.
It should have two obligatory parameters with types VBRP-VBELN and VBRP-POSNR.
In the report you should retrieve the whole text with FM READ_TEXT and display it in popup window. See an example below.
2.2. Create transaction for this report.
2.3. Add the drill-down report into your query.
- Open you query in SQ01
- Goto -> Report assignment
- In the popup window "Assign reports" press the "Insert row" button.
- in the next popup press "Other report type"
- choose "Transaction" and then enter your t-code.
- As a result, you should get somethink like this:
3. That is all.
Now, run your query.
If you want, you can double-click on the row and display the whole text. In my simple example it looks like that. Of course, it is better to use a popup with CL_GUI_TEXT_EDIT instead.
- - -
* Please note, that parameters types a the same as in Infoset
PARAMETERS: p_vbeln TYPE vbrp-vbeln OBLIGATORY,
p_posnr TYPE vbrp-posnr OBLIGATORY.
DATA lv_name TYPE tdobname.
DATA lt_item_txt TYPE TABLE OF tline.
DATA: lt_text_as_table TYPE TABLE OF tline.
FIELD-SYMBOLS: <fs_item_txt> LIKE LINE OF lt_item_txt.
CONCATENATE p_vbeln p_posnr INTO lv_name.
CALL FUNCTION 'READ_TEXT'
id = '0001'
language = 'R'
name = lv_name
object = 'VBBP'
lines = lt_item_txt
id = 1
OTHERS = 2.
IF sy-subrc = 0.
LOOP AT lt_item_txt ASSIGNING <fs_item_txt>.
APPEND <fs_item_txt> TO lt_text_as_table.
* Not excellent, but very fast example.
* In my opinion, it is better to display a popup window
* with CL_GUI_TEXTEDIT control.
* But implementation will take more time.
DATA: lr_salv TYPE REF TO cl_salv_table.
r_salv_table = lr_salv
t_table = lt_text_as_table