07-18-2013 8:39 AM
Hi All,
Here i am calling program rfitemar (Customer line item display) using SUBMIT statement and am exporting report output to memory.
you can see below code.
submit rfitemar with dd_kunnr-low = s_kunnr
with dd_bukrs-low = s_bukrs
with x_opsel = s_open_key exporting list to memory and return
with bilalist = ' ' " with classical list
with bilagrid = ' ' " no ALV grid
with bilatree = ' '. " no ALV tree .
Here i am extracting data from memory.
call function 'LIST_FROM_MEMORY'
tables
listobject = itab_list
exceptions
not_found = 4
others = 8.
Here i am converting HEX value to ASCI value .
call function 'LIST_TO_ASCI'
* EXPORTING
* list_index = -1
tables
listasci = vlist
listobject = itab_list
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
or
Converting into TXT fromat.
CALL FUNCTION 'LIST_TO_TXT'
*EXPORTING
* LIST_INDEX = -1
TABLES
listtxt = xtext
LISTOBJECT = itab_list
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
But the problem is extracted internal table data will be in the ABAP LIST format nothing but "Classical report/ALV List display format".
you can see the output below.
Body of the Internal table vlist[ ] is:
-----------------------------------------------------------------------------------------------------------------------------------------------------------
1
2 Customer 9000009
3 Company Code 5000
4
5 Name FMS Test Terms Bill To Customer - U
6 City Derry
7
8 ---------------------------------------- ----------------------------------------
9 | St|Assignment |DocumentNo|T yp|Doc. Date |S|DD| Amt in loc.cur.|LC
10 ---------------------------------------- ----------------------------------------
11 | | |1800000010|D R |06/01/2013| | | 1,000.00 |US
12 | | | |1800000011|D | R |06/11/2013| | | 2,000.00 |US |
13 | | | |1800000012|D | R |06/10/2013| | | 590.00 |US |
14 | | | |1800000020|D | R |07/08/2013| | | 200.00 |US |
15 | | | |1800000021|D | R |01/01/2013| | | 100.00 |US |
16 | | | |1800000022|D | R |07/08/2013| | | 100.00 |US |
17 | | | |1800000023|D | R |07/08/2013| | | 100.00 |US |
18 | | | |1800000024|D | R |07/08/2013| | | 100.00 |US |
19 | | | |1800000025|D | R |07/08/2013| | | 100.00 |US |
20 | | | |1800000026|D | R |07/08/2013| | | 100.00 |US |
21 | | | |1800000027|D | R |07/08/2013| | | 100.00 |US |
22 | | | |1800000028|D | R |07/08/2013| | | 200.00 |US |
-----------------------------------------------------------------------------------------------------------------------------------------------------------
My question is how to convert the above internal table data into rows and column dynamically (like normal internal table data)
Kindly help me on this.
Thanks & Regards,
Akshath.L.T
07-18-2013 10:18 AM
Create a table of the same type as in the output
loop on the itab you received and split on '|'.
SPLIT wa_itab AT '|' INTO <req_structure>.
APPEND <req+structure> INTO <required_table>.
Regards
07-18-2013 11:31 AM
Hi Mohammed,
I already implemented this logic, but the thing is its not dynamic, in feature if some buddy added extra fields our program work pick.
Is there any FM module to covert abap_list into internal table?
07-19-2013 3:19 AM
Well in taht case why not use an export import function in both reports rather than using import list.
In the Submit program write EXPORT of the internal table and IMPORT it whereever needed.
07-19-2013 4:59 AM
Hi akshath,
In that use this method...
07-18-2013 10:46 AM
Hi,
Try the below approach you can get the details into internal table.
" To disable the view
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_true
data = abap_true
).
"Call the report.
" it_gt_sel_tab TYPE TABLE OF rsparams,
SUBMIT (text-010) USING SELECTION-SCREEN '1000'
WITH SELECTION-TABLE it_gt_sel_tab
AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = gt_alv_table ).
ASSIGN gt_alv_table->* TO <f_alv_data>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE i003 DISPLAY LIKE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ). "clear the memory.
LOOP AT <f_alv_data> ASSIGNING <f_alv_wa>.
TRY .
MOVE <f_alv_wa> TO ZXXXXX_report.
APPEND ZXXXXXXXX TO it_gt_alv_out.
CATCH cx_sy_move_cast_error .
ENDTRY.
ENDLOOP.
You should identify the structure and use it to append it to your table.
Hope this solves the problem.
Note: this approach wont work for OOPS ALV concept.
Regards,
Arun.
07-19-2013 4:47 AM
Hi Akshath,
Try to use EXPORT and IMPORT statements, in the called program export your internal table and in the calling program import the exported internal table.
Ex:
To export use:
EXPORT itab INTO MEMORY ID 'ALV'.
To import use:
IMPORT itab FROM MEMBORY ID 'ALV'.
Regards,
Satish D R
11-21-2013 8:47 AM
hi akshath,
did you get any solution for this..
I am facing same problem with ABAP_LIST.
if you get the solution, please place the way you have got..
Thanks in Advance.
Thanks,
Kranthi Kumar M.
11-23-2013 6:25 PM
Hi Kranthi,
I have created classical report.
Please find below code
parameters: s_kunnr type kna1-kunnr,
S_BUKRS TYPE KNB1-BUKRS.
DATA: itab_list TYPE TABLE OF ABAPLIST.
* vlist TYPE ref to data.
"itab_list LIKE ABAPLIST.
data: begin of t_listout occurs 0,
line(1024) type c,
end of t_listout.
*xtext
data: vlist like abaplist occurs 0 with header line.
DATA: s_open_key,
X_AISEL value 'X'.
s_open_key = 'X'.
submit rfitemar with dd_kunnr-low = s_kunnr
with dd_bukrs-low = s_bukrs
* with x_opsel = s_open_key " XAISEL " XOPSEL
with X_AISEL = X_AISEL " XAISEL " XOPSEL
exporting list to memory and return
with bilalist = ' ' " with classical list
with bilagrid = ' ' " no ALV grid
with bilatree = ' '. " no ALV tree .
*Here i am extracting data from memory.
call function 'LIST_FROM_MEMORY'
tables
listobject = itab_list
exceptions
not_found = 4
others = 8.
*Here i am converting HEX value to ASCI value .
call function 'LIST_TO_ASCI'
* EXPORTING
* list_index = -1
tables
listasci = t_listout
listobject = itab_list
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
LOOP AT t_listout.
* if you wants to separate '|' use remove statement
write: / t_listout-line.
clear t_listout.
ENDLOOP.
-
11-26-2013 12:02 PM
You can use this below fm do display the record,
data: vlist1 like table of ABAPLIST.
vlist[] = vlist[].
CALL FUNCTION 'WRITE_LIST'
EXPORTING
WRITE_ONLY = 'X'
TABLES
listobject = itab_list
EXCEPTIONS
EMPTY_LIST = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if you want convert the text into internal table you need to use
you need to use split option.
am looking fm to convert text into internal table format.
if i get will share with you
11-26-2013 3:25 PM
Hello Akshath,
Check the code below for getting both raw data and metadata.
** retrieve data
cl_salv_bs_runtime_info=>set(
exporting display = abap_false
metadata = abap_true
data = abap_true ).
submit (program) using selection-set variant exporting list to memory
and return.
try.
cl_salv_bs_runtime_info=>get_data_ref(
importing r_data = lf_ref ).
assign lf_ref->* to <lt_data>.
if <lt_data> is not assigned.
message text-009 type 'E'.
endif.
catch cx_salv_bs_sc_runtime_info.
message text-009 type 'E'.
endtry.
try.
cl_salv_bs_runtime_info=>get_metadata(
receiving value = value
).
catch cx_salv_bs_sc_runtime_info.
message text-010 type 'E'.
endtry.
cl_salv_bs_runtime_info=>clear_all( ).
create data lf_ref1 like line of <lt_data>.
assign lf_ref1->* to <lt_line>.
** end retrieve data
** retrieve metadata
* cl_salv_bs_runtime_info=>set(
* exporting display = abap_false
* metadata = abap_true
* data = abap_true ).
* submit (program) using selection-set variant exporting list to memory
* and return.
* try.
* cl_salv_bs_runtime_info=>get_metadata(
* receiving value = value
* ).
* catch cx_salv_bs_sc_runtime_info.
* message text-010 type 'E'.
* endtry.
* cl_salv_bs_runtime_info=>clear_all( ).
** retrieve metadata
Best regards,
Kerim
11-27-2013 12:20 PM
hi
u try this 2 simply program,
1 st
SELECT-OPTIONS : S_MATNR FOR mara-MATNR MATCHCODE OBJECT Z_MB5B_F4_HELP.
HBEWERTAR1 = HBEWERTAR.
DATA : OPTION(32) TYPE C.
option = 'PPIOD000'.
EXPORT OPTION TO MEMORY ID 'MEM_OPT'.
SUBMIT ZSLD_TEST_AMOL_1 WITH S_MATNR IN S_MATNR
* EXPORTING LIST TO MEMORY
AND RETURN.
IMPORT t_mara FROM MEMORY ID 'MEM_ITAB1'.
*IMPORT LISTOBJECT FROM MEMORY ID '%_LIST'.
FREE MEMORY ID: 'MEM_ITAB','MEM_ITAB1','MEM_ITAB2'.
if t_mara[] is not INITIAL.
write : 'secsefull done'.
ELSE.
write : 'secsefull not done'.
ENDIF.
2nd
*&---------------------------------------------------------------------*
*& Report ZSLD_TEST_AMOL_1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSLD_TEST_AMOL_1.
TABLES mara.
data : t_mara type TABLE OF mara,
w_mara TYPE mara.
DATA: option(32) TYPE c.
SELECT-OPTIONS s_matnr FOR mara-matnr.
IMPORT option FROM MEMORY ID 'MEM_OPT'.
FREE MEMORY ID 'OPTION'.
SELECT * from mara into TABLE t_mara WHERE matnr in s_matnr.
EXPORT t_mara TO MEMORY ID 'MEM_ITAB1'.
11-28-2013 8:58 AM
Hi,
DELETE vlist FROM 1 TO 11.
Fill the required fields.
LOOP AT vlist INTO wa_vlist.
SPLIT wa_vlist-value AT '|' INTO wa_final-dummy
wa_final-vbeln
wa_final-vbelp
wa_final-menge.
append wa_final to it_final.
ENDLOOP.
Regards
Bharath