HOW TO CONVERT STRUCTURE INTO INTERNAL TABLE
HOW TO CONVERT STRUCTURE INTO INTERNAL TABLE
lets declare a structure --
data: begin of str,
name(10),
age(3),
city(10),
end of str.
lets now convert this to an internal table itab --
data itab like table of str.
I hope this helps
regards,
-pankaj singh
Similar Messages
-
How to convert rows of internal table to columns of another internal table?
Hi,
Experts,
test_data.xls:
one two three four five
one two three four
one two three
one two
one
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = 'c:/test_data.xls'
I_BEGIN_COL = '1'
I_BEGIN_ROW = '1'
I_END_COL = '10'
I_END_ROW = '10'
TABLES
INTERN = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
output:
0001 0001 one
0001 0002 two
0001 0003 three
0001 0004 four
0001 0005 five
0002 0001 one
0002 0002 two
0002 0003 three
0002 0004 four
0003 0001 one
0003 0002 two
0003 0003 three
0004 0001 one
0004 0002 two
0005 0001 one
but i want this format:
one two three four five
one two three four
one two three
one two
one
i don't want this type of output display i want to display in ABAP report as in file format how can i achieve this post some ideas on it.
Thank U,
Shabeer ahmed.Hi,
Use this piece of code :
parameters: p_flname type rlgrap-filename.
data:
li_filecontent type standard table of alsmex_tabline ,
lwa_filecontent type alsmex_tabline ,
lv_begin_col type i value 1,
lv_begin_row type i value 1,
lv_end_col type i value 17,
lv_end_row type i value 65000,
li_fieldlist type lvc_t_fcat,
li_data type ref to data,
dy_line type ref to data.
field-symbols:<dyntable> type standard table,
<fs_data> type ref to data,
<fs_1>,
<dyn_wa>,
<dyn_field>.
*Transfer excel file contents to internal table
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_flname
i_begin_col = lv_begin_col
i_begin_row = lv_begin_row
i_end_col = lv_end_col
i_end_row = lv_end_row
tables
intern = li_filecontent
exceptions
inconsistent_parameters = 1
upload_ole = 2
error_message = 3
others = 4.
if sy-subrc = 0.
*Creating the list of fields in the table
perform f_create_tab_field tables li_fieldlist using 'BUKRS' 4 .
perform f_create_tab_field tables li_fieldlist using 'ZPOC_KUNNR' 10 .
perform f_create_tab_field tables li_fieldlist using 'RANL' 13.
perform f_create_tab_field tables li_fieldlist using 'ZPEDAT' 10 .
perform f_create_tab_field tables li_fieldlist using 'KWERT' 15 .
perform f_create_tab_field tables li_fieldlist using 'BONUS' 2 .
perform f_create_tab_field tables li_fieldlist using 'WAERS' 5 .
perform f_create_tab_field tables li_fieldlist using 'ZVAL' 15 .
perform f_create_tab_field tables li_fieldlist using 'ZQTY' 15 .
perform f_create_tab_field tables li_fieldlist using 'KMEIN' 3 .
assign li_data to <fs_data>.
*CREATING INTERNAL TABLE TO store data
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = li_fieldlist
importing
ep_table = <fs_data>
exceptions
generate_subpool_dir_full = 1
others = 2.
if sy-subrc = 0.
assign <fs_data>->* to <fs_1>.
assign <fs_1> to <dyntable>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyntable>. " creating a line type of the table just created above
assign dy_line->* to <dyn_wa>. " creating the work area with reference to the line type
loop at li_filecontent into lwa_filecontent.
assign component lwa_filecontent-col "accessing corresponding field in the field catalog
of structure <dyn_wa> to <dyn_field>. "and assigning this field to a field symbol
if sy-subrc = 0.
<dyn_field> = lwa_filecontent-value. " filling value for this field
endif.
at end of row.
append <dyn_wa> to <dyntable>.
clear <dyn_wa>.
endat.
clear lwa_filecontent.
endloop.
i_input_file[] = <dyntable>.
endif.
elseif sy-subrc <> 0.
message s027 display like c_error with text-001.
stop.
endif.
form f_create_tab_field tables p_li_fieldlist structure lvc_s_fcat
using p_fname
p_lenght.
data:lwa_fieldlist type lvc_s_fcat.
lwa_fieldlist-fieldname = p_fname.
lwa_fieldlist-intlen = p_lenght.
append lwa_fieldlist to p_li_fieldlist.
clear lwa_fieldlist.
endform. " F_CREATE_TAB_FIELD
Regards,
Dev. -
How to save message into internal table?
Hi,everyone!
I have a problem when I'm coding.I want to store messages into a internal table.Can you help me?
Thanks!Hello Feng
If you are already working on SAP basis release >= 6.20 I would recommend the most versatile message handler of all: interface <b>IF_RECA_MESSAGE_LIST</b>
Perhaps you will find the following sample report ZUS_SDN_APOLLO_13
(see also: <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack">Message Handling - Finding the Needle in the Haystack</a>) useful.
*& Report ZUS_SDN_APOLLO_13
REPORT zus_sdn_apollo_13
LINE-SIZE 200.
TYPE-POOLS: abap.
TYPES: BEGIN OF ty_s_outtab.
TYPES: status TYPE exception.
INCLUDE TYPE bapiret2 AS msg.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gs_layout TYPE lvc_s_layo,
gt_outtab TYPE ty_t_outtab.
DATA:
gd_title TYPE lvc_title,
gd_msgv TYPE symsgv,
gd_msg TYPE bapi_msg,
gs_msg TYPE recamsg,
gs_return TYPE bapiret2,
gt_return TYPE bapirettab,
go_msglist TYPE REF TO if_reca_message_list,
go_random TYPE REF TO cl_random_number,
gif_random TYPE REF TO if_random_number.
PARAMETERS:
p_opt1 RADIOBUTTON GROUP radi DEFAULT 'X',
p_opt2 RADIOBUTTON GROUP radi,
p_opt3 RADIOBUTTON GROUP radi.
SELECTION-SCREEN ULINE.
PARAMETERS:
p_opt4 RADIOBUTTON GROUP radi,
p_opt5 RADIOBUTTON GROUP radi,
p_opt6 RADIOBUTTON GROUP radi.
SELECTION-SCREEN ULINE.
PARAMETERS:
p_count TYPE numc3 DEFAULT '4',
p_level TYPE ballevel DEFAULT '7'.
DEFINE mac_build_msg.
clear: gs_msg.
gs_msg-msgty = &5.
gs_msg-msgid = '00'.
gs_msg-msgno = '398'.
gs_msg-msgv1 = &1.
gs_msg-msgv2 = &2.
gs_msg-msgv3 = &3.
gs_msg-msgv4 = &4.
gs_msg-detlevel = &6.
END-OF-DEFINITION.
* msgty
* msgid
* msgno
* msgv1
* msgv2
* msgv3
* msgv4
* msgv1_src
* msgv2_src
* msgv3_src
* msgv4_src
* detlevel
* probclass
* alsort
* time_stmp
* msg_count
* context
* params
START-OF-SELECTION.
" Create message handler
go_msglist = cf_reca_message_list=>create( ).
" Create random number instance
CREATE OBJECT go_random TYPE cl_random_number.
gif_random ?= go_random.
gif_random->init( ).
PERFORM message_handling_1.
PERFORM message_handling_2.
PERFORM message_handling_3.
PERFORM message_handling_4.
END-OF-SELECTION.
*& Form MESSAGE_HANDLING_1
* text
* --> p1 text
* <-- p2 text
FORM message_handling_1 .
CHECK ( p_opt1 = abap_true ).
gd_title = 'Information System 1 (IS1)'.
SET TITLEBAR 'TITLE' WITH gd_title.
WRITE: / 'Apollo 13 Mission'.
WRITE: / syst-uline.
WRITE: / 'Take-Off -> ok'.
WRITE: / 'Leaving Orbit -> ok'.
WRITE: / 'Trajectory -> ok'.
WRITE: /.
FORMAT COLOR COL_NEGATIVE.
WRITE: / 'Explosion happened -> not ok'.
WRITE: / 'Command and Service module (CSM) -> damaged'.
FORMAT RESET.
WRITE: / 'Lunar module (LM) -> not affected, ok'.
MESSAGE text-hou TYPE 'S'.
ENDFORM. " MESSAGE_HANDLING_1
*& Form message_handling_2
* text
* --> p1 text
* <-- p2 text
FORM message_handling_2 .
* define local data
DATA:
ld_success(6) TYPE n,
ld_warning(6) TYPE n,
ld_failure(6) TYPE n,
ld_total(6) TYPE n.
CHECK ( p_opt2 = abap_true ).
gd_title = 'Information System 2 (IS2)'.
SET TITLEBAR 'TITLE' WITH gd_title.
PERFORM generate_messages. " simulation of messages
CALL METHOD go_msglist->get_list_as_bapiret
IMPORTING
et_list = gt_return.
" Calculate message types and total
ld_total = 0.
ld_success = 0.
ld_warning = 0.
ld_failure = 0.
" Print messages as WRITE list
LOOP AT gt_return INTO gs_return.
IF ( gs_return-type = 'E' ).
ADD 1 TO ld_failure.
ELSEIF ( gs_return-type = 'W' ).
ADD 1 TO ld_warning.
ELSE.
ADD 1 TO ld_success.
ENDIF.
ENDLOOP.
ld_total = ld_success + ld_warning + ld_failure.
WRITE: / 'Total Message =', ld_total.
WRITE: / 'Failures =', ld_failure.
WRITE: / 'Warnings =', ld_warning.
WRITE: / 'Successes =', ld_success.
WRITE: / syst-uline.
SKIP.
" Colouring depending on message type
LOOP AT gt_return INTO gs_return.
IF ( gs_return-type = 'E' ).
FORMAT COLOR COL_NEGATIVE.
ELSEIF ( gs_return-type = 'W' ).
FORMAT COLOR COL_TOTAL.
ELSE.
FORMAT RESET.
ENDIF.
WRITE: / gs_return-type, gs_return-message+0(100).
ENDLOOP.
ENDFORM. " message_handling_2
*& Form message_handling_3
* text
* --> p1 text
* <-- p2 text
FORM message_handling_3 .
* define local data
DATA:
ls_outtab TYPE ty_s_outtab.
DATA:
ld_success(6) TYPE n,
ld_warning(6) TYPE n,
ld_failure(6) TYPE n,
ld_total(6) TYPE n.
CHECK ( p_opt3 = abap_true ).
gd_title = 'Information System 3 (IS3)'.
SET TITLEBAR 'TITLE' WITH gd_title.
PERFORM generate_messages. " simulation of messages
CALL METHOD go_msglist->get_list_as_bapiret
IMPORTING
et_list = gt_return.
REFRESH: gt_outtab.
" Calculate message types and total
ld_total = 0.
ld_success = 0.
ld_warning = 0.
ld_failure = 0.
" Define the logic for setting exception status (LED)
LOOP AT gt_return INTO gs_return.
CLEAR: ls_outtab.
ls_outtab-msg = gs_return.
IF ( gs_return-type = 'E' ).
ls_outtab-status = '1'. " red
ADD 1 TO ld_failure.
ELSEIF ( gs_return-type = 'W' ).
ls_outtab-status = '2'. " yellow
ADD 1 TO ld_warning.
ELSE.
ls_outtab-status = '3'. " green
ADD 1 TO ld_success.
ENDIF.
APPEND ls_outtab TO gt_outtab.
ENDLOOP.
ld_total = ld_failure + ld_warning + ld_success.
CLEAR: gs_layout.
gs_layout-cwidth_opt = abap_true.
gs_layout-zebra = abap_true.
gs_layout-excp_fname = 'STATUS'.
gs_layout-excp_led = abap_true.
gs_layout-smalltitle = abap_true.
CONCATENATE 'T(' ld_total ') '
'E(' ld_failure ') '
'W(' ld_warning ') '
'S(' ld_success ') '
INTO gd_title SEPARATED BY space.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_structure_name = 'BAPIRET2'
i_grid_title = gd_title
is_layout_lvc = gs_layout
TABLES
t_outtab = gt_outtab
EXCEPTIONS
OTHERS = 1.
ENDFORM. " message_handling_3
*& Form message_handling_4
* text
* --> p1 text
* <-- p2 text
FORM message_handling_4 .
* define local data
CHECK ( p_opt4 = abap_true OR
p_opt5 = abap_true OR
p_opt6 = abap_true ).
IF ( p_opt4 = abap_true ).
gd_title = 'Information System 4 (IS4)'.
SET TITLEBAR 'TITLE' WITH gd_title.
ELSEIF ( p_opt5 = abap_true ).
gd_title = 'Information System 5 (IS5)'.
SET TITLEBAR 'TITLE' WITH gd_title.
ELSE.
gd_title = 'Information System 6 (IS6)'.
SET TITLEBAR 'TITLE' WITH gd_title.
ENDIF.
PERFORM generate_messages. " simulation of messages
PERFORM display_log.
ENDFORM. " message_handling_4
*& Form GENERATE_MESSAGES
* text
* --> p1 text
* <-- p2 text
FORM generate_messages .
* define local data
mac_build_msg 'Apollo 13 Mission: Spacecraft'
space space space 'I' '1'.
** DEFINE mac_build_msg.
** clear: gs_msg.
** gs_msg-msgty = &5.
** gs_msg-msgid = '00'.
** gs_msg-msgno = '398'.
** gs_msg-msgv1 = &1.
** gs_msg-msgv2 = &2.
** gs_msg-msgv3 = &3.
** gs_msg-msgv4 = &4.
** gs_msg-detlevel = &6.
** END-OF-DEFINITION.
go_msglist->add( is_message = gs_msg ).
DO 6 TIMES.
CASE syst-index.
WHEN '1'.
mac_build_msg 'Command and Service Module (CSM)'
space space space 'I' '2'.
WHEN '2'.
mac_build_msg 'Lunar Module (LM)' space space space 'I' '2'.
WHEN '3'.
mac_build_msg 'Additional Module (M-1)'
space space space 'I' '2'.
WHEN '4'.
mac_build_msg 'Additional Module (M-2)'
space space space 'I' '2'.
WHEN '5'.
mac_build_msg 'Additional Module (M-3)'
space space space 'I' '2'.
WHEN '6'.
mac_build_msg 'Additional Module (M-4)'
space space space 'I' '2'.
WHEN OTHERS.
EXIT.
ENDCASE.
go_msglist->add( is_message = gs_msg ).
" recursive call of routine
PERFORM generate_messages_1 USING syst-index 'Modul' '3'.
ENDDO.
ENDFORM. " GENERATE_MESSAGES
*& Form GENERATE_MESSAGES_1
* text
* --> p1 text
* <-- p2 text
FORM generate_messages_1
USING
value(ud_index) TYPE i
value(ud_msgv) TYPE symsgv
value(ud_detlevel) TYPE ballevel.
* define local data
DATA:
ld_integer TYPE i,
ld_msgty TYPE symsgty,
ld_msgv TYPE symsgv,
ld_detlevel TYPE ballevel.
DO p_count TIMES.
WRITE syst-index TO ld_msgv NO-ZERO LEFT-JUSTIFIED.
IF ( ud_detlevel = '3' ).
CONCATENATE ud_msgv ld_msgv INTO ld_msgv
SEPARATED BY space.
ELSE.
CONCATENATE ud_msgv ld_msgv INTO ld_msgv
SEPARATED BY '.'.
ENDIF.
CONDENSE ld_msgv.
gd_msgv = ld_msgv.
IF ( ud_index = 1 ).
ld_integer = gif_random->get_random_int( 300 ).
IF ( ld_integer = 1 ).
ld_msgty = 'E'.
CONCATENATE gd_msgv 'failed' INTO gd_msgv SEPARATED BY ' -> '.
ELSEIF ( ld_integer BETWEEN 1 AND 10 ).
ld_msgty = 'W'.
CONCATENATE gd_msgv 'check(?)' INTO gd_msgv SEPARATED BY ' -> '.
ELSE.
ld_msgty = 'S'.
CONCATENATE gd_msgv 'OK' INTO gd_msgv SEPARATED BY ' -> '.
ENDIF.
ELSE.
ld_msgty = 'S'.
CONCATENATE gd_msgv 'OK' INTO gd_msgv SEPARATED BY ' -> '.
ENDIF.
mac_build_msg gd_msgv space space space ld_msgty ud_detlevel.
go_msglist->add( is_message = gs_msg ).
IF ( ud_detlevel < p_level ).
ld_detlevel = ud_detlevel + 1.
PERFORM generate_messages_1 USING ud_index ld_msgv ld_detlevel.
ENDIF.
ENDDO.
ENDFORM. " GENERATE_MESSAGES_1
*& Form DISPLAY_LOG
* text
* --> p1 text
* <-- p2 text
FORM display_log .
* define local data
DATA:
ld_handle TYPE balloghndl,
lt_log_handles TYPE bal_t_logh,
ls_profile TYPE bal_s_prof.
" Get log handle of collected message list
ld_handle = go_msglist->get_handle( ).
APPEND ld_handle TO lt_log_handles.
IF ( p_opt4 = 'X' ).
* get a display profile which describes how to display messages
CALL FUNCTION 'BAL_DSP_PROFILE_DETLEVEL_GET'
IMPORTING
e_s_display_profile = ls_profile. " tree & ALV list
ELSEIF ( p_opt5 = 'X' ).
* get standard profile to display one log
CALL FUNCTION 'BAL_DSP_PROFILE_SINGLE_LOG_GET'
IMPORTING
e_s_display_profile = ls_profile.
ELSE.
CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
IMPORTING
e_s_display_profile = ls_profile.
ENDIF.
* set report to allow saving of variants
ls_profile-disvariant-report = sy-repid.
* when you use also other ALV lists in your report,
* please specify a handle to distinguish between the display
* variants of these different lists, e.g:
ls_profile-disvariant-handle = 'LOG'.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = ls_profile
i_t_log_handle = lt_log_handles
EXCEPTIONS
profile_inconsistent = 1
internal_error = 2
no_data_available = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_LOG
Regards
Uwe -
How to Fetch Data into internal table column wise?
The internal table contains huge set of data. Normally we fetch the data row wise using insert and select statements in work area.
But, the requirement is on fetching the data column wise for each field from the database.
So,can anyone help me on this issue for fetching the data column wise?Welcome to SDN.
What you want to do(if I understand correctly) is not possible with the statements available to us. You could do it, but I think it would be a lot of code and I don't think that its worth it. Why exactly do you want to do this?
Regards,
Rich Heilman -
How to append structure into transperant table in sap abap
Hi all,
I have 1 structure already in the data dictionary .
And this structure is already being used by other transperant table for creatin the fields .
Now i need to create new table and wann use the same structure .
when i click on the Append Structure it shows that this structure us already been assign to other table .
So, can i not used the same structure for more than 1 transperant table |???
PraffHi Prafful,
You cannot append the same structure, if already used.
I think you can include the structure instead of appending it.
Goto the change mode (CTRL+F1).
Edit -> Include -> Insert.
Hope this helps...
Lokesh
pls. reward appropriate points -
Converting worbook data into internal table
Hi,
I'm using a FM 'RRMX_WORKBOOK_READ' to read data from a workbook in BI system. My requirement is to get the data into an internal table and I'm using the above FM for this purpose. But the above FM gives data in binary format.... Anbody has any idea how to convert this into internal table format.
Thanks,
Mahesh M.S.get the spool output in raw format using function module
data: it_raw type table of soli.
call function 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = i_spool_nr
FIRST_LINE = 1
LAST_LINE = 1000000000000
desired_type = 'RAW'
IMPORTING
REAL_TYPE =
SP_LANG =
tables
buffer = it_raw
BUFFER_PDF =
exceptions
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
if the required format is XLS add tabs to split the columns.
constants con_tab type c value cl_abap_char_utilities=>horizontal_tab.
if i_doctype = 'XLS'.
replace all occurrences of '|' in table t_attachment with con_tab.
endif.
Then use 'SO_DOCUMENT_SEND_API1' fucntion module to send XLS file as attachment -
Fetch data into internal table
Hi all,
I want to fetch all the opbel records from erdk table into an intrnal table.
Only opbel records.There are 100000000 records in erdk table.
How can I fetch into internal table ? what statement can I use to fetch the data faster keepin performance into consideration ?
Many thanksHi,
As far as data fetch is concerned you do the same as follows:
Select * from erdk into table itab
where..... < Your Where Condition if any>.
But as the number of records are very high, first try to put all the primary keys in the where clause and also if possible, try to narrow down the selection criteria by fetching data from some other table or widening the conditions in where clause.
Also try to fetch only thode fields which you actually need.
else your program will give performance problems.
Hope this helps!
Regards,
Lalit -
How to convert xml file into internal table in ABAP Mapping.
Hi All,
I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
<BookingCode>2KY34R</BookingCode>
- <Passenger>
<Name>SARVESH</Name>
<Address>THANE</Address>
</Passenger>
- <Passenger>
<Name>RAJESH</Name>
<Address>POWAI</Address>
</Passenger>
- <Passenger>
<Name>CARRON</Name>
<Address>JUHU</Address>
</Passenger>
- <Flight>
<Date>03/03/07</Date>
<AirlineID>UA</AirlineID>
<FlightNumber>125</FlightNumber>
<From>LAS</From>
<To>SFO</To>
</Flight>
</ns0:MTO_ABAP_MAPPING>
AT the receiver side I wnat to concatenate the NAME & ADDRESS.
I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
but couldnt succeed to convert the xml file into internal table perfectly.
Can anybody help on this.
Thanks in advance!!
SarveshHi Sarvesh,
The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
Just in case you have not seen this
regards
Vijaya -
How to get data of tabulated text file into internal table
hi all,
i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding how to convert excel file into internal table but i didnt get posts regarding text file.
thanks
SAchintry:
DATA: BEGIN OF tabulator,
x(1) TYPE x VALUE '09',
END OF tabulator.
READ DATASET file INTO wa.
split wa at tabulator into table itab.
A. -
How to create an dynamic internal table with the structure of a ddic table
Hi all,
I want to fill ddic-tables (which I already created) in my abap dictionary with data out of CSV-files (which are located on the CRM-Server). The ddic tables have different amount of fields.
I started with creating a table which contains the name of the tables and the path to the matching CSV-file.
At the beginning I'm filling an internal table with part of this data (the name of the ddic-tables) - after that I am looping at this internal table.
LOOP AT lt_struc ASSIGNING <lfs_struc>.
LOOP AT lv_itab1 INTO lv_wa1 WHERE ztab_name = <lfs_struc>.
lv_feld = lv_wa1-zdat_name.
ENDLOOP.
CONCATENATE 'C:\-tmp\Exportierte Tabellen\' lv_feld INTO lv_pfad.
Do.
OPEN DATASET lv_pfad FOR INPUT IN TEXT MODE ENCODING NON-UNICODE IGNORING CONVERSION ERRORS.
READ DATASET lv_pfad INTO lv_rec.
IF sy-subrc NE 0.
EXIT.
ENDIF.
enddo.
REPLACE ALL OCCURRENCES OF '"' IN lv_rec WITH ''.
SPLIT lv_rec AT ';' INTO TABLE lt_str_values.
INSERT into (<lfs_struc>) values lr_str_value.
CLOSE DATASET lv_pfad.
endloop.
This is not the whole code, but it's working until
SPLIT lv_rec AT ';' INTO TABLE lt_str_values.
I want to split all the data of lv_rec into an internal table which has the structure of the current ddic-table, but I didn't find out how to do give the internal table the structure of the ddic-table. In the code I used an internal tyble type string but I should be the structure of the matching tabel.
If I try to create an internal table by using a fiel symbol, I am told, that the data types are not matching.
Has anyone an idea?Hi Mayari,
though you were successfull with
METHOD cl_alv_table_create=>create_dynamic_table
I must warn you not to use it. The reason is that the number of tables created is limited, the method uses GENERATE SUBROUTINE statement and this triggers an unwanted database commit.
If you know the DDIC structure, it is (starting with ECC6.0) much easier:
field-symbols:
<table> type standard table.
data:
lr_data type ref to data.
Create data lr_data type table of (<DDIC structure>).
assign lr_data->* to <table>.
The split code can be simplified gaining speed loosing complexity not loosing functionality.
field-symbols:<fs_s> type any.
field-symbols:<fs_t> type any.
SPLIT lv_rec AT ';' INTO table it_string.
loop at it_string assigning <fs_s>.
assign component sy-tabix of wa_string to <fs_t>.
if sy-subrc = 0.
<fs_t> = <fs_s>.
endif.
at last.
append <fs_itwa3> to <ft_itab3>.
endat.
endloop.
Though it may work as Keshav.T suggested, there is no need to do that way.
Regards,
Clemens -
How to read xml with deep structure into intarnal table.
Hi,
Could you pls any body provide xslt code for deep structure convert into internal table.
sample xml file:
- <ns0:CREATIONOFCONTRACT xmlns:ns0="http://BPCreationXSD.CreationOfContract">
- <CREATIONOFCONTRACTDATA>
<RequestType>L0011</RequestType>
<ApplicationId>AN-12</ApplicationId>
<LoanId>QO-22</LoanId>
- <Borrowerguarantorinfo>
<Borrowerbpno>101020</Borrowerbpno>
<Co-borrower1BPNo>101021</Co-borrower1BPNo>
<Co-borrower2BPNo>101022</Co-borrower2BPNo>
<Guarantor1BPNo>101023</Guarantor1BPNo>
<Guarantor2BPNo>101024</Guarantor2BPNo>
<Branch>New Delhi</Branch>
</Borrowerguarantorinfo>
- <Loaninfo>
<Applicationtype>Fresh</Applicationtype>
<Purposeofloan>Home Purchase</Purposeofloan>
<Securedunsecuredflag>Secured</Securedunsecuredflag>
<Loantype>HL with MRTA</Loantype>
<Loancurrency>INR</Loancurrency>
<Loanproduct>MaxiHome Loan Package</Loanproduct>
<Loanscheme>MaxiHome ZEC</Loanscheme>
<Loanamount>1500000.00</Loanamount>
<Loantenure>60</Loantenure>
<Tiered>No</Tiered>
</Loaninfo>
<Periodfrom>01/07/2009</Periodfrom>
<Periodto>16/09/2019</Periodto>
<RateType>Fixed</RateType>
<Ratecode>10.25</Ratecode>
</CREATIONOFCONTRACTDATA>
</ns0:CREATIONOFCONTRACT>Hi Ramesh,
Thanks for the info,but I found lot of tables unfortunately I am not getting the value for radio buttons. Also I found a FM FIELD_SELECTION_CUSTOMIZE , IMPORT_DYNPRO etc which will call that screen based on profile but it will not store data any where. I found several tables like TCATS, TFAWC, TFAWF, TFAWT etc.But I am not getting the value for raduio buttons.
Thanks & Regards,
Nagaraj Kalbavi -
How to transfer data of RFC into Internal Table inside a WD4A program?
Hi Experts,
I have created WD4A program. This program calls RFC. The output of RFC has to populate a UI table. THe different cells of the table should have different color based on data.
I have gone through following link:
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/707fb792-c181-2d10-61bd-ce15d58b5cf1
The above link fetches data from directly from table. Then it passes the data into internal table.
If I am using RFC, then how I can insert data of RFC into a internal table in WD4A program (se80 In drop down Web Dynpro Comp / Intf)
My motto is to have table ouput whose different cells should have different color based on data.
Please help.
Regards,
Gary
Edited by: Jason Lax on Dec 28, 2011 2:52 PM (Fixed broken link)Hi Experts,
I have resolved the issue. I have created WD4A program. This WD4A program calls the RFC.
The RFC has a structure as export parameters called 'RESULT_FINAL'. I have altered the associated type of this table export parameter. I added Component 'Color' of component type 'WDUI_TABLE_CELL_DESIGN'.
In the RFC I have added some code. The code is as below:
loop at it_t1.
select pernr from pa0000 into table it_t2 where pernr = it_t1-pernr and stat2 ='3'
and begda <= sy-datum AND endda >= sy-datum.
if sy-subrc = 0.
result_final-org_unit = result_objec-objid.
result_final-pernr = it_t1-pernr.
result_final-name = it_t1-name.
result_final-color = '02'. append result_final.
endif.
endloop.
The line result_final-color = '02'.
code returns Color.
In the WD4A program, I have changed the Cell Design property of selected table coloumn to Color.
This resolved the issue.
Thanks every one for the reply.
I have added above information for other SDN users.
I am closing this thread,
Regards,
Gary -
How to transfer excel files(on ftp server) into internal table?
hello,everyone
pls tell me how to transfer excel files those on a ftp server into internal table?
ps.i know the function 'ftp_server_to_r3',it can help to transfer flat file.Hi,
I believe you want to get the data from the FTP Server to R3.
I am also sending the code. Have a look and it would help you.
First get the Password and user name and the FTP Server Path where file is stored and FTP Server Host name
FUNCTION zfi_ftp_get.
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_FILENAME) TYPE C
*" TABLES
*" T_BLOB STRUCTURE ZFI_TLM_LENGTH OPTIONAL " is a table type with a field called line of length 992
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
DATA : i_password(30) TYPE c,
i_user(30) TYPE c,
i_host(30) TYPE c,
i_rfc_destination TYPE rfcdes-rfcdest,
i_length TYPE i,
i_folder_path(100) TYPE c.
DATA: lv_blob_length TYPE i.
DATA: lv_length TYPE i, "Password length
lv_key TYPE i VALUE 26101957,
lv_password(30) TYPE c,
lv_ftp_handle TYPE i,
lv_cmd(80) TYPE c.
DATA: BEGIN OF result OCCURS 0,
line(100) TYPE c,
END OF result.
TYPES: BEGIN OF ty_dummy,
line(392) TYPE c,
END OF ty_dummy.
DATA: lt_dummy TYPE TABLE OF ty_dummy,
ls_dummy LIKE LINE OF lt_dummy.
i_password = 'vnhdh'.
i_user = 'sdkgd'.
i_host = 'sbnksbg'.
i_rfc_destination = 'SAPFTP'.
i_length = '992'.
i_folder_path = '/hioj/hohjk/hh'.
lv_length = STRLEN( i_password ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = i_password
sourcelen = lv_length
key = lv_key
IMPORTING
destination = lv_password.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = i_user
password = lv_password
host = i_host
rfc_destination = i_rfc_destination
IMPORTING
handle = lv_ftp_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc = 1.
return-type = 'E' .
return-message = 'FTP Connection not Successful'.
APPEND return.
ELSEIF sy-subrc = 2.
return-type = 'E' .
return-message = 'FTP Connection not Successful'.
APPEND return.
ELSEIF sy-subrc EQ 0.
return-type = 'S' .
return-message = 'FTP Connection Successful'.
APPEND return.
CONCATENATE 'cd' i_folder_path INTO lv_cmd SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = lv_ftp_handle
command = lv_cmd
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc = 1.
return-type = 'E' .
return-message = 'Command Error Occured during open of FTP Folder'.
APPEND return.
ELSEIF sy-subrc = 2.
return-type = 'E' .
return-message = 'TCIP Error Occured during open of FTP Folder'.
APPEND return.
ELSE.
REFRESH t_blob.
lv_blob_length = 992.
TRANSLATE i_filename TO LOWER CASE.
CALL FUNCTION 'FTP_SERVER_TO_R3'
EXPORTING
handle = lv_ftp_handle
fname = i_filename
IMPORTING
blob_length = lv_blob_length
TABLES
blob = lt_dummy.
t_blob[] = lt_dummy[].
ENDIF.
ENDIF.
ENDFUNCTION.
Regards
Sajid
Edited by: shaik sajid on Nov 16, 2010 7:25 AM -
How to store output of SQ01 into internal table.
Hello Experts
How to store output of SQ01 into internal table.
Thanks,
UmeshYou can't store the sq01 output into internal table.
Once you create the query it will generate the abap program, in that program you can see the contents.
Regards
Sasi -
How to join THREE different tables into internal table using one select statement .
How to join THREE different tables into internal table using one select statement .
Hi experts,
I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
Scenario:
Database tables:
SPFLI
SFLIGHT
SBOOK.
Table Fields:
SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
SEATSOCC_C SEATSMAX_F SEATSOCC_F
SBOOK - CARRID CONNID CLASS
MY INTERNAL TABLE IS IT_XX.
Your help much appreciated.
Thanks in advance.
Pawan.Hi Pawan,
please check below codes. hope it can help you.
TYPES: BEGIN OF ty_xx,
carrid TYPE spfli-carrid ,
connid TYPE spfli-connid ,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom ,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto ,
fldate TYPE sflight-fldate ,
seatsmax TYPE sflight-seatsmax ,
seatsocc TYPE sflight-seatsocc ,
seatsmax_b TYPE sflight-seatsmax_b,
seatsocc_b TYPE sflight-seatsocc_b,
seatsmax_f TYPE sflight-seatsmax_f,
seatsocc_f TYPE sflight-seatsocc_f,
class TYPE sbook-class,
END OF ty_xx,
t_xx TYPE STANDARD TABLE OF ty_xx.
DATA: it_xx TYPE t_xx.
SELECT spfli~carrid
spfli~connid
spfli~countryfr
spfli~cityfrom
spfli~countryto
spfli~cityto
sflight~fldate
sflight~seatsmax
sflight~seatsocc
sflight~seatsmax_b
sflight~seatsocc_b
sflight~seatsmax_f
sflight~seatsocc_f
sbook~class
INTO TABLE it_xx
FROM spfli INNER JOIN sflight
ON spfli~carrid = sflight~carrid
AND spfli~connid = sflight~connid
INNER JOIN sbook
ON spfli~carrid = sbook~carrid
AND spfli~connid = sbook~connid.
Thanks,
Yawa
Maybe you are looking for
-
How do I vertically align paragraphs in a page?
I am new to Pages, and I've run across a problem that is really aggravating because it should not be rocket science... but it seems to be, at least for me. I need to center the text on the page so there is equal white space above and below it. In Wor
-
Can i get Pictures off of a broken
my iphone 4 has just stopped working and the power button has been broke for weeks so i cant even restart the phone. Also it is not being recognised when i plug it into my computer. Is there anyway at all that i can get my phots from the broken phone
-
Our old iMac died and we got a new one. The problem is that our entire iTunes library was on the old iMac and all of our iPads and iPhones were synced to the old dead iMac. How do we sync the devices to the new iMac now?
-
Image deletion won't display in browser
Hey everyone, simplly put I am displaying a picture I have created to the user, after it is displayed I wish to delete it from my drive, the only problem is that the image is deleted before it is displayed, i want it the other way round. I have creat
-
Error Code 150:30 when opening up CS4
When opening up CS4 I receive Error Code 150:30, what is this??