Field-Symbols: How to retrieve data into an internal table from FS
Hello All,
I am working on field symbols.I have declared the field symbols as shown.
FIELD-SYMBOLS: <gt_pos_data> TYPE table,
<wa_pos_data> like <gt_pos_data>.
Data: Begin of itab occurs 0,
field1(5) type c,
field2(10)_type c,
end of itab.
The FS <gt_pos_data> has 100 fields but I need to move only two fields from this FS to my internal table itab.I am doing the following.
loop at <gt_pos_data> assigning <wa_pos_data>.
itab-field1 = <wa_pos_data>-field1.
itab-field2 = <wa_pos_data>-field2.
append itab.
clear itab.
endloop.
But it is giving me an error saying "<wa_pos_data> is a table without header line and therefore has no componet FIELD1".How to achieve this requirement?
Thanks in advance
Sandeep
<wa_pos_data> should be defined LIKE LINE OF <gt_pos_data>, but it will still have no structure, so you need to assign a field symbol to the component as well.
FIELD-SYMBOLS: <gt_pos_data> TYPE table,
<wa_pos_data> like LINE OF <gt_pos_data>,
<field> type any.
Data: Begin of itab occurs 0,
field1(5) type c,
field2(10)_type c,
end of itab.
loop at <gt_pos_data> assigning <wa_pos_data>.
assign componet 'FIELD1' of structure <wa_pos_data> to <field>.
if sy-subrc = 0.
itab-field1 = <field>.
endif.
assign componet 'FIELD2' of structure <wa_pos_data> to <field>.
if sy-subrc = 0.
itab-field2 = <field>.
endif.
append itab.
clear itab.
endloop.
Regards,
Rich Heilman
Similar Messages
-
To add the multiline data into an internal table from TextEdit
Hello Experts,
I have one requirement that I have to use the TextEdit field. and put the values into an internal table.
can you help me. with some sample code.
Thanks in Advance
KuldeepThe problem is solved by using the following code
DATA: data TYPE REF TO CL_HTMLB_TEXTEDIT.
Data itab1 type itab.
data ?= CL_HTMLB_MANAGER=>GET_DATA(
request = runtime->server->request
name = 'textEdit'
id = 'txt1'
data text type string.
IF data IS NOT INITIAL.
text = data->text.
ENDIF.
SPLIT text AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO
TABLE itab1.
Kuldeep -
How to populate data into Dynamic Internal Table.
Hi Experts,
I had created one Dynamic Internal table and one static internal table.I want to move data from Static Internal table to Dynamic interal table.And aslo the number of coloum of these two tables are not same.
So please help me for solving this issue.
Thanks,
<u><i><b>Seema.</b></i></u>Hi,
Check out this sample program for dynamictable report.
REPORT YMS_DYNAMICDEMO
NO STANDARD PAGE HEADING
MESSAGE-ID zcs_c2c_001.
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab.
perform get_data.
perform write_out.
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
form get_data.
Select Data from table.
select * into table <dyn_table>
from (p_table).
endform.
form write_out.
Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index
of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
endform.
Thanks,
Shankar -
How to insert data into custom database table from an hcsf
i want to insert data into database table that i have created from an hcsf.
example :
say i have created a table in oracle database and i hav created a hcsf file.now i want that when somebody fills in that hcsf and click submit ,i want that entries should be updated in my database table.
plzzz reply ASAP(it's urgent)you'll need a bit of Java code... extract the data during a check-in filter, and insert it into the database.
check out the "DataAccess" component in the HowToComponents for query-running examples, and the "DynamicPrefix" component for a check-in filter example.
I have older copies here:
http://bezzotech.com/library -
How to get records into two internal tables from 1 internal table?
VERME LGPLA
252.000 EA 300 0149A 410 0149
276.000 EA 300 0149A 410 0107
516.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
I have above records in my one internal table ITAB.
I want to divide these records in to two internal tables ITAB1 and ITAB2. and this is based on LGPLA and VERME.
If there is same LGPLA (last column) and different VERME (1st column) available, then it should append ITAB1
Otherwise it should append ITAB2.
ITAB1 should contain ,
516.000 EA 300 0149A 400 3013
ITAB2 should contain ,
252.000 EA 300 0149A 410 0149
276.000 EA 300 0149A 410 0107
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
I have tried with this code
Loop at itab .
IF lv_prev_lgpla = wa-lgpla and lv_prev_verme <> wa-verme.
APPEND wa TO itab1.
else.
APPEND wa TO itab2.
endif.
lv_prev_lgpla = wa-vlpla.
lv_prev_verme = wa-anfme.
Endloop.
But it contains,
516.000 EA 300 0149A 400 3013
in table ITAB2 which I dont want.
Points rewarded soon.
Regards,
RonnDear Ronny,
i am gining the solution below.But would request you to change your ITAB STRUCTURE LIKE THIS BEFORE USING THE CODE
VERME LGPLA
252.000 EA 300 0149A 0149 410
276.000 EA 300 0149A 0107 410
516.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
then do as follows.
SORT ITAB BY LGPLA VERME.
LOOP AT ITAB INTO WITAB.
W_INDEX = SY-TABIX.
here take all the abOve fields in temp fieds.
LW_VERME = WITAB-VERME..AND SO ON.
AT END OF LGPLA.
MOVE: all LW fields to work area of ITAB1
APPEND work area of ITAB1 TO ITAB1.
DELETE ITAB INDEX W_INDEX
ENDAT.
ENDLOOP.
Basically what u r doing here is thet u r using processing event.
So whenerv VERME changes this event will be triggered.
Just try this out...something like this only will be he logic.
Please let me know further -
How to import data into a Z table from excel file?
hi,
i have a custom created Z table into which i want to import some data from an excel file. which function can i use to do so because SE16 allows me to insert data only one by one via a data entry screen. this is time consuming. i want to import data from excel file so that its faster.HI,
this program uploads data from excel and modifies ztable,(inserts records into ztable), check this and modify according to ur requirement)
This program uploads material number from excel sheet and does
******modifications to material number if required by the user
******and updates the table zmatnr with new material against the old material number
REPORT zmat_no message-id zebg.
TYPE-POOLS truxs.
TABLES:zmatnr.
DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA row LIKE alsmex_tabline-row.
data : g_matnr like mara-matnr.
data : count type i.
data : itab_count type i.
data : gi_final like zmatnr occurs 0 with header line.
*data : begin of gi_final occurs 0,
mat_old like mara-matnr,
mat_new like mara-matnr,
end of gi_final.
***********************Selection Screen*************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.
select-options : records for count.
SELECTION-SCREEN END OF BLOCK b1.
*********************At Selection Screen*************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.
PERFORM search.
START-OF-SELECTION.
perform process.
form process.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = pfname
i_begin_col = 1
i_begin_row = 2
i_end_col = 12
i_end_row = 65000
TABLES
intern = itab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 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.
describe table itab lines itab_count.
row = 1.
loop at itab.
if itab-row <> row.
append gi_final.
clear gi_final.
endif.
case itab-col.
when '1'.
CLEAR G_MATNR.
gi_final-OLD_MATNR = itab-value.
CONCATENATE 'NEW' gi_final-old_matnr INTO itab-value.
gi_final-new_MATNR = itab-value.
endcase.
row = itab-row.
append gi_final.
clear gi_final.
endloop.
CALL FUNCTION 'PROGRESS_INDICATOR'
EXPORTING
I_TEXT = 'File Has Been Successfully Uploaded from Workstation ' .
if not gi_final[] is initial.
if not records-low is initial .
if not records-high is initial.
records-high = records-high + 1.
DESCRIBE TABLE gi_final LINES count.
IF records-high < count.
DELETE gi_final FROM records-high TO count.
ENDIF.
IF records-low <> 1.
IF records-low <> 0.
DELETE gi_final FROM 1 TO records-low.
ENDIF.
ENDIF.
endif.
endif.
endif.
IF NOT GI_FINAL[] IS INITIAL.
CALL FUNCTION 'PROGRESS_INDICATOR'
EXPORTING
I_TEXT = 'Processing zmatnr table'
I_OUTPUT_IMMEDIATELY = 'X'.
if itab_count <> count.
message i000 with 'records are not matching'.
exit.
else.
modify zmatnr from table gi_final.
message i000 with 'data base table modified successfully'.
endif.
endif.
endform.
*& Form search
text
--> p1 text
<-- p2 text
FORM search .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = pfname.
ENDFORM. " search
regards
siva -
Select data into deep internal table
Dear Experts.
I created a dynamiv deep internal table.
while selecting data , into the internal table it is giving a dump. saying that deep structure.
SELECT OBJTY OBJID ARBPL WERKS from crhd
INTO CORRESPONDING FIELDS OF TABLE <f_tab>
where WERKS = pr_werks.
I used the field catalog also.even same error is comming.
how to get data into deep internal table by select statement.
Please help me,
Regards,
RahulHI,
Try creating dynamic internal table like:
Field-symbols: <dyn_table> type standard table,
<dyn_wa> ,
<dyn_field>.
Data: dy_table type ref to data,
ifc type lvc_t_fcat ,
xfc type lvc_s_fcat ,
Count type i ,
Count1 type i ,
Index type i ,
dy_line type ref to data.
Data counter type i.
Data: line type string ,
List like table of line.
Data: idetails type abap_compdescr_tab,
xdetails type abap_compdescr .
Data: ref_table_des type ref to cl_abap_structdescr.
*Looping at field cat internal table to populate another field cat to be passed
* In method used below for creating final dynamic internal table
Loop at fieldcat into fieldcat1.
Clear xfc.
Xfc-fieldname = fieldcat1-fieldname.
Xfc-datatype = fieldcat1-datatype.
Xfc-intlen = fieldcat1-intlen.
Append xfc to ifc.
endloop.
Clear fieldcat1.
*Method called to create dynamic internal table on the basis of field catalog created above
Call method cl_alv_table_create=>create_dynamic_table
Exporting
it_fieldcatalog = ifc u201Cfield catalog appended above
Importing
ep_table = dy_table. u201CDynamic internal table which will be created
Assign dy_table->* to <dyn_table>.
*Create dynamic work area and assign to FS
Create data dy_line like line of <dyn_table>.
Assign dy_line->* to <dyn_wa>.
Then use this dynamic internal table created from above method
in the Select Query.
Hope it helps
Regards
Mansi -
How can i add two table data into third internal table see below
hi i insert diffferent table data into different internal table i did try to insert two different internal table data into third internal table by using move
but only single data is coming please help me
i want this two internal table data inot third internal table.
sELECT * FROM J_1IEXCHDR INTO CORRESPONDING FIELDS OF ITAB1 WHERE STATUS = 'P'.
SELECT * FROM J_1IEXCDTL INTO CORRESPONDING FIELDS OF ITAB2 WHERE LIFNR = J_1IEXCHDR-LIFNR.
AND DOCYR = J_1IEXCHDR-DOCYR,
AND DOCNO = J_1IEXCHDR-DOCNO.
WRITE: / ITAB1-LIFNR,
ITAB1-DOCNO,
ITAB1-EXYEAR,
ITAB1-BUDAT,
ITAB2-EXBED,
ITAB2-RDOC,
ITAB2-ECS.
ENDSELECT.
ENDSELECT.
thank you .hi
Two add two internal tables data. first we need to create third internal table with all the fields of first two internal tables.
later u move the two internal tables data to third internal table
by looping the internal table which have more records or depending on the requirement and move the corresponding fields of first internal table to the third internal table and use the read statement with condition based on primary key of first itab and get the corresponding data of 2table into 3table.
i am sending the sample code to u.
check it out. i think u will understand how to move.
select vbeln waerk netwr erdat audat kunnr
into table it_vbeln
from vbak
where vbeln in s_vbeln
and erdat in s_erdat.
if not it_vbeln[] is initial.
select kunnr name1
into table it_kunnr
from kna1
for all entries in it_vbeln
where kunnr = it_vbeln-kunnr.
endif.
loop at it_vbeln.
clear it_final.
it_final-vbeln = it_vbeln-vbeln.
it_final-waerk = it_vbeln-waerk.
it_final-netwr = it_vbeln-netwr.
it_final-erdat = it_vbeln-erdat.
it_final-audat = it_vbeln-audat.
read table it_kunnr with key kunnr = it_vbeln-kunnr.
it_final-name1 = it_kunnr-name1.
append it_final.
endloop. -
How to insert data into the mysql table by giving as a text file
Hi,
Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
Thanks:)At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).
-
How to read a table and transfer the data into an internal table?
Hello,
I try to read all the data from a table (all attribute values from a node) and to write these data into an internal table. Any idea how to do this?
Thanks for any help.Hi,
Check this code.
Here i creates context one node i.e flights and attributes are from SFLIGHT table.
DATA: lo_nd_flights TYPE REF TO if_wd_context_node,
lo_el_flights TYPE REF TO if_wd_context_element,
ls_flights TYPE if_main=>element_flights,
it_flights type if_main=>elements_flights.
navigate from <CONTEXT> to <FLIGHTS> via lead selection
lo_nd_flights = wd_context->get_child_node( 'FLIGHTS' ).
CALL METHOD LO_ND_FLIGHTS->GET_STATIC_ATTRIBUTES_TABLE
IMPORTING
TABLE = it_flights.
now the table data will be in internal table it_flights. -
How to send multiple row data into an internal table??
I have a view with table control.i want to select multiple row and send all the row data into an internal table.i am able to select multiple row but all the selected row data is not going to the internal table.....only a particular row data which is lead selected is going.
Do anyone can help me regarding this issue?
Thanks in advance,
Subhasis.Hey,
Some code example:
declaring an internal table and work area to get all the elements from the node.
data : lt_Elements type WDR_CONTEXT_ELEMENT_SET,
ls_Element type WDR_CONTEXT_ELEMENT_SET,
considering flights is my node.
lt_data type sflight.
Node_Flights is the ref of the node to which ur table is binded.
Use Code Inspector to read the node.
lt_Element = Node_Flights->GET_ELEMENTS
loop at lt_elements into ls_Element.
l_bollean = ls_elements->is_selected ( returns abap true/false ).
if l_bollean IS INITIAL.
append ls_Element to lt_data.
endif.
Hope this would help.
Cheers,
Ashish -
Insert data into a database table from a string
Hi,
I am need to insert data into a table from the text file. I pull the data into an internal table using GUI_UPLoad. I read the data into an internal table and concatenate data into a string. I need to do this because the structure of the table is dynamic. it is used to upload a series of tables each with different structure, But the data is stored in the string v_tabledata. How to do that.
after uploading the data from the textt file into a table
oop at i_final.
v_tabname = i_final-table_name.
concatenate i_final-table_rec1 i_final-table_rec2 i_final-table_rec3
i_final-table_rec4 i_final-table_rec5 into v_tabledata.
from 'v_table data' i need to upload the data into a table and the structue of the table is known dynamically. Any thoughts using field symbols?
Thanks,
VGLet me see if I've understood your issue
You have a file to be uploaded into an internal table but this file has many different layouts and then you don't know how to link these fields with the internal table...is it your issue?
Then you've read the internal table, you've sent it to a string divided by space or something else and then are you trying to read this string to send it to a table?
We could read the standard tables which maintain the program names, table names etc... (DD* tables, as the DD03L table) and then create some rules...
We could create a parameter table to read your file/table dynamically...
Please, try to rewrite in other words your problem...because there are a lot of ways to achieve your issue...
Alexandre Mendes -
Header data and item data into same internal table
Hi Experts,
I WANT TO KNOW THE LOGIC TO POPULATE HEADER DATA AND ITEM DATA INTO SAME INTERNAL TABLE AND AGAIN DOWNLOAD THE SAME TO EXCEL FILE .Output file should be displayed like this format
Header1 rectyp ,hdnum ,sbank ,bankl ,accnr , paytp , crda ,iso.
Item1 : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
Item2 : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
Header2: rectyp ,hdnum ,sbank ,bankl ,accnr , paytp , crda ,iso.
Item1 : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
Thanks
Moderator message: Please do not use all upper case in the future.
Edited by: Thomas Zloch on May 12, 2010 3:10 PMHi,
for example we have 3 internal tables
1> it_header 2>it_items 3>it_final (which contains all the header and item fields)
once it_header it_items are filled
loop at it_items.
read table it_header with key xyz = it_item-xyz.
if sy-subrc = 0.
here move all the header fields to it_final like below.
it_final -xfield = it_header-xfield.
endif.
here move all the item fields to it_final like below.
it_final -yfield = it_item-yfield.
append it_final.
clear it_final.
endloop.
now header and item fileds will be fillled in it_item -
Download the KTOPL field data and GLT0 table data into one Internal table
Hi,
I have downloaded GLT0 table fields data to PC file . But i need to download KTOPL(Chart Of Accounts) data also. in GLT0 table there is no KTOPL field.
But in SKA1 table have KTOPL field. Then what is the issue is GLT0 data & KTOPL field data needs to download into one Internal Table.
anybody could you please solve this problem. immediately need to solve this.
Below is the code.
REPORT ZFXXEABL_1 NO STANDARD PAGE HEADING
LINE-SIZE 200.
Tables Declaration
TABLES : GLT0.
Data Declaration
DATA : FP(8) TYPE C,
YEAR LIKE GLT0-RYEAR,
PERIOD(3) TYPE C,
DBALANCE LIKE VBAP-NETWR VALUE 0 ,
CBALANCE LIKE VBAP-NETWR VALUE 0.
*Internal table for for final data..
DATA : BEGIN OF REC1 OCCURS 0,
BAL LIKE GLT0-TSLVT value 0,
COAREA LIKE GLT0-RBUSA,
CA(4) TYPE C,
KTOPL LIKE ska1-ktopl,
CCODE LIKE GLT0-BUKRS,
CREDIT LIKE VBAP-NETWR,
CURRENCY LIKE GLT0-RTCUR,
CURTYPE(2) TYPE N,
DEBIT LIKE VBAP-NETWR,
YEAR(8) TYPE C,
FY(2) TYPE C,
ACCOUNT LIKE GLT0-RACCT,
VER LIKE GLT0-RVERS,
VTYPE(2) TYPE N,
CLNT LIKE SY-MANDT,
S_SYS(3) TYPE C,
INDICATOR LIKE GLT0-DRCRK,
END OF REC1.
DATA : C(2) TYPE N,
D(2) TYPE N.
DATA REC1_H LIKE REC1.
Variable declarations
DATA :
W_FILES(4) TYPE N,
W_DEBIT LIKE GLT0-TSLVT,
W_CREDIT LIKE GLT0-TSLVT,
W_PCFILE LIKE RLGRAP-FILENAME ,
W_UNIXFILE LIKE RLGRAP-FILENAME,
W_PCFILE1 LIKE RLGRAP-FILENAME,
W_UNIXFIL1 LIKE RLGRAP-FILENAME,
W_EXT(3) TYPE C,
W_UEXT(3) TYPE C,
W_PATH LIKE RLGRAP-FILENAME,
W_UPATH LIKE RLGRAP-FILENAME,
W_FIRST(1) TYPE C VALUE 'Y',
W_CFIRST(1) TYPE C VALUE 'Y',
W_PCFIL LIKE RLGRAP-FILENAME.
DATA: "REC LIKE GLT0 OCCURS 0 WITH HEADER LINE,
T_TEMP LIKE GLT0 OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF REC3 OCCURS 0.
INCLUDE STRUCTURE GLT0.
DATA: KTOPL LIKE SKA1-KTOPL,
END OF REC3.
DATA: BEGIN OF T_KTOPL OCCURS 0,
KTOPL LIKE SKA1-KTOPL,
SAKNR LIKE SKA1-SAKNR,
END OF T_KTOPL.
Download data.
DATA: BEGIN OF I_REC2 OCCURS 0,
BAL(17), " like GLT0-TSLVT value 0,
COAREA(4), " like glt0-rbusa,
CA(4), " chart of accounts
CCODE(4), " like glt0-bukrs,
CREDIT(17), " like vbap-netwr,
CURRENCY(5), " like glt0-rtcur,
CURTYPE(2), " type n,
DEBIT(17), " like vbap-netwr,
YEAR(8), " type c,
FY(2), " type c, fiscal yr variant
ACCOUNT(10), " like glt0-racct,
VER(3), " like glt0-rvers,
VTYPE(3), " type n,
CLNT(3), "like sy-mandt,
S_SYS(3), "like sy-sysid,
INDICATOR(1), " like glt0-drcrk,
END OF I_REC2.
Selection screen. *
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
SELECT-OPTIONS : COMPCODE FOR GLT0-BUKRS,
GLACC FOR GLT0-RACCT,
FISYEAR FOR GLT0-RYEAR,
no intervals no-extension, "- BG6661-070212
FISCPER FOR GLT0-RPMAX,
busarea for glt0-rbusa,
CURRENCY FOR GLT0-RTCUR.
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME TITLE TEXT-BL2.
PARAMETERS:
P_UNIX AS CHECKBOX, "Check box for Unix Option
P_UNFIL LIKE RLGRAP-FILENAME, " Unix file Dnload file name
default '/var/opt/arch/extract/GLT0.ASC', "- BG6661-070212
P_PCFILE AS CHECKBOX, "Check box for Local PC download.
P_PCFIL LIKE RLGRAP-FILENAME " PC file Dnload file name
default 'C:\GLT0.ASC'. "- BG6661-070212
DEFAULT 'C:\glt0_gl_balance_all.asc'. "+ BG6661-070212
SELECTION-SCREEN END OF BLOCK BL2.
*eject
Initialization. *
INITIALIZATION.
Try to default download filename
p_pcfil = c_pcfile.
p_unfil = c_unixfile.
if sy-sysid eq c_n01.
p_unfil = c_unixfile.
endif.
if sy-sysid eq c_g21.
p_unfil = c_g21_unixfile.
endif.
if sy-sysid eq c_g9d.
p_unfil = c_g9d_unixfile.
endif.
Default for download filename
*{ Begin of BG6661-070212
CONCATENATE C_UNIXFILE
SY-SYSID C_FSLASH C_CHRON C_FILENAME INTO P_UNFIL.
*} End of BG6661-070212
AT SELECTION-SCREEN OUTPUT.
loop at screen.
if screen-name = 'P_PCFIL'. "PC FILE
screen-input = '0'.
modify screen.
endif.
if screen-name = 'P_UNFIL'. "UN FILE
screen-input = '0'.
modify screen.
endif.
endloop.
if w_first = 'Y'.
perform path_file.
w_first = 'N'.
endif.
if w_cfirst = 'Y'.
perform cpath_file.
w_cfirst = 'N'.
endif.
Start-of-Selection. *
START-OF-SELECTION.
*COLLECT DATA
PERFORM COLLECT_DATA.
*BUILD FILENAMES
PERFORM BUILD_FILES.
*LOCAL
IF P_PCFILE = C_YES.
PERFORM LOCAL_DOWNLOAD.
ENDIF.
*UNIX
IF P_UNIX = C_YES.
PERFORM UNIX_DOWNLOAD.
ENDIF.
IF P_PCFILE IS INITIAL AND P_UNIX IS INITIAL.
MESSAGE I000(ZL) WITH 'Down load flags both are unchecked'.
ENDIF.
END-OF-SELECTION.
IF P_PCFILE = C_YES.
WRITE :/ 'PC File' , C_UNDER, P_PCFIL.
ENDIF.
*& Form DOWNLOAD
Download *
FORM DOWNLOAD.
P_PCFIL = W_PATH.
DATA LIN TYPE I.
DESCRIBE TABLE I_REC2 LINES LIN.
WRITE:/ 'No of Records downloaded = ',LIN.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = P_PCFIL
FILETYPE = C_ASC "c_dat "dat
TABLES
DATA_TAB = I_REC2 " t_str
fieldnames = t_strhd
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
IF SY-SUBRC EQ 0.
ENDIF.
ENDFORM.
*& Form WRITE_TO_SERVER
text *
--> p1 text
<-- p2 text
FORM WRITE_TO_SERVER.
DATA : L_MSG(100) TYPE C,
L_LINE(5000) TYPE C.
P_UNFIL = W_UPATH.
DATA LIN TYPE I.
DESCRIBE TABLE I_REC2 LINES LIN.
WRITE:/ 'No of Records downloaded = ',LIN.
OPEN DATASET P_UNFIL FOR OUTPUT IN TEXT MODE. " message l_msg.
IF SY-SUBRC <> 0.
WRITE: / L_MSG.
ENDIF.
perform header_text1.
LOOP AT I_REC2.
TRANSFER I_REC2 TO P_UNFIL.
ENDLOOP.
CLOSE DATASET P_UNFIL.
WRITE : / C_TEXT , W_UPATH.
SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
CLEAR W_UPATH.
IF NOT W_UEXT IS INITIAL.
CONCATENATE W_UNIXFIL1 C_DOT W_UEXT INTO W_UPATH.
ELSE.
W_UEXT = C_ASC. " c_csv.
CONCATENATE W_UNIXFIL1 C_DOT W_UEXT INTO W_UPATH.
ENDIF.
ENDFORM. " WRITE_TO_SERVER
*& Form BUILD_FILES
FORM BUILD_FILES.
IF P_PCFILE = C_YES.
W_PCFILE = P_PCFIL.
***Split path at dot**
SPLIT W_PCFILE AT C_DOT INTO W_PCFILE1 W_EXT.
IF NOT W_EXT IS INITIAL.
CONCATENATE W_PCFILE1 C_DOT W_EXT INTO W_PATH.
ELSE.
W_PATH = W_PCFILE1.
ENDIF.
ENDIF.
IF P_UNIX = C_YES.
W_UNIXFILE = P_UNFIL.
SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
IF NOT W_UEXT IS INITIAL.
CONCATENATE W_UNIXFIL1 C_DOT W_UEXT INTO W_UPATH.
ELSE.
W_UPATH = W_UNIXFIL1.
ENDIF.
ENDIF.
ENDFORM.
FORM CPATH_FILE.
CLEAR P_PCFIL.
CONCATENATE C_PCFILE
C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
C_DOT C_ASC INTO P_PCFIL.
ENDFORM. " CPATH_FILE
FORM PATH_FILE.
CLEAR P_UNFIL.
if sy-sysid eq c_n01.
CONCATENATE C_UNIXFILE
C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
C_DOT C_ASC INTO P_UNFIL.
endif.
if sy-sysid eq c_g21.
concatenate c_g21_unixfile
c_comfile sy-sysid c_under sy-datum sy-uzeit
c_dot c_asc into p_unfil.
endif.
if sy-sysid eq c_g9d.
concatenate c_g9d_unixfile
c_comfile sy-sysid c_under sy-datum sy-uzeit
c_dot c_asc into p_unfil.
endif.
ENDFORM. " PATH_FILE
Local_Download *
Local *
FORM LOCAL_DOWNLOAD.
perform header_text.
LOOP AT REC1.
REC1-CLNT = SY-MANDT.
REC1-S_SYS = SY-SYSID.
MOVE: REC1-BAL TO I_REC2-BAL,
REC1-COAREA TO I_REC2-COAREA,
REC1-CA TO I_REC2-CA,
REC1-KTOPL TO I_REC2-CA,
REC1-CCODE TO I_REC2-CCODE,
REC1-CREDIT TO I_REC2-CREDIT,
REC1-CURRENCY TO I_REC2-CURRENCY,
REC1-CURTYPE TO I_REC2-CURTYPE,
REC1-DEBIT TO I_REC2-DEBIT,
REC1-YEAR TO I_REC2-YEAR,
REC1-FY TO I_REC2-FY,
REC1-ACCOUNT TO I_REC2-ACCOUNT,
REC1-VER TO I_REC2-VER,
REC1-VTYPE TO I_REC2-VTYPE,
REC1-CLNT TO I_REC2-CLNT,
REC1-S_SYS TO I_REC2-S_SYS,
REC1-INDICATOR TO I_REC2-INDICATOR.
APPEND I_REC2.
CLEAR I_REC2.
ENDLOOP.
IF NOT I_REC2[] IS INITIAL.
PERFORM DOWNLOAD .
CLEAR I_REC2.
REFRESH I_REC2.
ELSE.
WRITE : / ' no record exist due to unavailability of data'.
ENDIF.
ENDFORM. " LOCAL_DOWNLOAD
*& Form UNIX_DOWNLOAD
FORM UNIX_DOWNLOAD.
LOOP AT REC1.
REC1-CLNT = SY-MANDT.
REC1-S_SYS = SY-SYSID.
MOVE: REC1-BAL TO I_REC2-BAL,
REC1-COAREA TO I_REC2-COAREA,
REC1-CA TO I_REC2-CA,
REC1-KTOPL TO I_REC2-CA,
REC1-CCODE TO I_REC2-CCODE,
REC1-CREDIT TO I_REC2-CREDIT,
REC1-CURRENCY TO I_REC2-CURRENCY,
REC1-CURTYPE TO I_REC2-CURTYPE,
REC1-DEBIT TO I_REC2-DEBIT,
REC1-YEAR TO I_REC2-YEAR,
REC1-FY TO I_REC2-FY,
REC1-ACCOUNT TO I_REC2-ACCOUNT,
REC1-VER TO I_REC2-VER,
REC1-VTYPE TO I_REC2-VTYPE,
SY-MANDT TO I_REC2-CLNT,
SY-SYSID TO I_REC2-S_SYS,
REC1-INDICATOR TO I_REC2-INDICATOR.
APPEND I_REC2.
CLEAR I_REC2.
ENDLOOP.
IF NOT I_REC2[] IS INITIAL.
PERFORM WRITE_TO_SERVER.
CLEAR I_REC2.
REFRESH I_REC2.
ELSE.
WRITE : / ' no record exist due to unavailability of data'.
ENDIF.
ENDFORM. " UNIX_DOWNLOAD
*& Form HEADER_TEXT
text *
--> p1 text
<-- p2 text
*form header_text.
concatenate c_bal c_ba c_ca c_cc c_credit c_currency c_curtype
c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
into t_strhd
separated by c_comma.
append t_strhd.
*endform. " HEADER_TEXT
*& Form HEADER_TEXT1
text *
*form header_text1.
concatenate c_bal c_ba c_ca c_cc c_credit c_currency c_curtype
c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
into t_strhd1
separated by c_comma.
append t_strhd1.
transfer t_strhd1 to p_unfil.
*endform. " HEADER_TEXT1
*& Form COLLECT_DATA
Collect Data *
FORM COLLECT_DATA.
SELECT * FROM GLT0 INTO TABLE REC3
WHERE BUKRS IN COMPCODE
AND RYEAR IN FISYEAR
AND RPMAX IN FISCPER
AND RACCT IN GLACC
AND RTCUR IN CURRENCY.
SELECT KTOPL FROM SKA1
INTO TABLE T_KTOPL
FOR ALL ENTRIES IN REC3
WHERE SAKNR = REC3-RACCT.
LOOP AT REC3 .
select *
from glt0
into table t_temp
where rldnr = rec-rldnr
and rrcty = rec-rrcty
and rvers = rec-rvers
and bukrs = rec-bukrs
and ryear = rec-ryear
and racct = rec-racct
and rbusa = rec-rbusa
and rtcur <> 'ZAR'
and rpmax = rec-rpmax.
if sy-subrc = 0.
rec1-bal = '0.00'.
else.
rec1-bal = rec-hslvt.
endif.
*READ TABLE T_KTOPL WITH KEY SAKNR = REC-RACCT BINARY SEARCH.
MOVE T_KTOPL-KTOPL TO REC3-KTOPL.
CLEAR: CBALANCE, DBALANCE.
REC1-BAL = REC3-HSLVT.
IF REC3-DRCRK = 'S'.
IF REC3-HSLVT NE C_ZERO.
YEAR = REC-RYEAR.
PERIOD = '000'.
CONCATENATE PERIOD C_DOT YEAR INTO FP.
REC1-INDICATOR = REC-DRCRK.
REC1-DEBIT = C_ZERO.
REC1-CREDIT = C_ZERO.
REC1-CCODE = REC-BUKRS.
REC1-YEAR = FP.
REC1-CURRENCY = REC-RTCUR.
REC1-ACCOUNT = REC-RACCT.
rec1-bal = rec-hslvt.
dbalance = rec1-bal.
REC1-CURTYPE = C_CTYPE.
REC1-FY = C_FY.
REC1-COAREA = REC-RBUSA.
REC1-VER = REC-RVERS.
REC1-VTYPE = C_CTYPE.
REC1-CA = C_CHART.
APPEND REC1.
C = 0.
PERFORM D.
ENDIF.
IF REC3-HSL01 NE C_ZERO.
YEAR = REC3-RYEAR.
PERIOD = '001'.
CONCATENATE PERIOD C_DOT YEAR INTO FP.
REC1-INDICATOR = REC3-DRCRK.
REC1-DEBIT = REC3-HSL01 .
REC1-CCODE = REC3-BUKRS.
REC1-YEAR = FP.
REC1-CURRENCY = REC3-RTCUR.
REC1-ACCOUNT = REC3-RACCT.
rec1-bal = REC3-hsl01 + dbalance.
dbalance = rec1-bal.
REC1-CURTYPE = C_CTYPE.
REC1-FY = C_FY.
REC1-COAREA = REC3-RBUSA.
REC1-VER = REC3-RVERS.
REC1-VTYPE = C_CTYPE.
REC1-CA = C_CHART.
REC1-KTOPL = REC3-KTOPL.
APPEND REC1.
C = 1.
PERFORM D.
ENDIF.
IF REC3-HSL02 NE C_ZERO.
REC1-DEBIT = REC3-HSL02.
YEAR = REC3-RYEAR.
PERIOD = '002'.
CONCATENATE PERIOD C_DOT YEAR INTO FP.
REC1-INDICATOR = REC3-DRCRK.
REC1-DEBIT = REC3-HSL02.
REC1-CCODE = REC3-BUKRS.
REC1-YEAR = FP.
REC1-CURRENCY = REC3-RTCUR.
REC1-ACCOUNT = REC3-RACCT.
rec1-bal = REC3-hsl02 + dbalance.
dbalance = rec1-bal.
REC1-CURTYPE = C_CTYPE.
REC1-FY = C_FY.
REC1-COAREA = REC3-RBUSA.
REC1-VER = REC3-RVERS.
REC1-VTYPE = C_CTYPE.
REC1-CA = C_CHART. "-BF7957-070503
REC1-KTOPL = REC3-KTOPL. "+BF7957-070503
APPEND REC1.
C = 2.
PERFORM D.
ENDIF.
IF REC3-HSL03 NE C_ZERO.
YEAR = REC3-RYEAR.
PERIOD = '003'.
CONCATENATE PERIOD C_DOT YEAR INTO FP.
REC1-INDICATOR = REC3-DRCRK.
REC1-DEBIT = REC3-HSL03.
REC1-CCODE = REC3-BUKRS.
REC1-YEAR = FP.
REC1-CURRENCY = REC3-RTCUR.
REC1-ACCOUNT = REC3-RACCT.
rec1-bal = REC3-hsl03 + dbalance .
dbalance = rec1-bal.
REC1-CURTYPE = C_CTYPE.
REC1-FY = C_FY.
REC1-COAREA = REC3-RBUSA.
REC1-VER = REC3-RVERS.
REC1-VTYPE = C_CTYPE.
REC1-CA = C_CHART. "-BF7957-070503
REC1-KTOPL = REC3-KTOPL. "+BF7957-070503
APPEND REC1.
C = 3.
PERFORM D.
ENDIF.
IF REC3-HSL04 NE C_ZERO.
REC1-DEBIT = REC3-HSL04.
YEAR = REC3-RYEAR.
PERIOD = '004'.
CONCATENATE PERIOD C_DOT YEAR INTO FP.
REC1-INDICATOR = REC3-DRCRK.
REC1-DEBIT = REC3-HSL04.
REC1-CCODE = REC3-BUKRS.
REC1-YEAR = FP.
REC1-CURRENCY = REC3-RTCUR.
REC1-ACCOUNT = REC3-RACCT.
rec1-bal = REC3-hsl04 + dbalance .
REC1-CURTYPE = C_CTYPE.
REC1-FY = C_FY.
REC1-COAREA = REC3-RBUSA.
REC1-VER = REC3-RVERS.
REC1-VTYPE = C_CTYPE.
REC1-CA = C_CHART. "-BF7957-070503
REC1-KTOPL = REC3-KTOPL. "+BF7957-070503
APPEND REC1.
dbalance = rec1-bal.
C = 4.
PERFORM D.
ENDIF.
Thanks and Regards,
Ramuse logical database SDF, nodes ska1 and skc1c
A. -
How to transfer Data of One internal table to another
Dear Guru,
I have an internal table
DATA: BEGIN OF t_cust OCCURS 0,
kschl LIKE rv13a-kschl,
werks LIKE komg-werks,
matnr LIKE komg-matnr,
kbetr LIKE konp-kbetr,
datab LIKE rv13a-datab,
datbi LIKE rv13a-datbi,
END OF t_cust.
I want to tranfer all the contents of internal table "t_cust" into another internal table "t_cust2" after converting kbetr, datab, datbi fields into char type.
How i will do it??
pls hlp..Hi Saifur,
if the structure is same then you can simply do
itab1[] = itab2[].
if you are changing the data type then.
data: wa1 like itab1,
wa2 like itab2.
loop at itab1 into wa.
wa2-field1 = wa1-field1.
wa2-field2 = wa1-field2.
Append wa2 to itab2.
endloop.
Maybe you are looking for
-
Screen hangs and then reloads when i right click a folder or any object in windows 8.1
when ever i right click something like a picture,docx,folder etc the cursor shows the loading sign and does not load right-click menu and after showing the loading sign for a few seconds, screen hangs(screen becomes white-ish) and after few more seco
-
Adobe Reader X - will not open PDFs
When I double click PDFs - they do not open. I have Win 7, 64-Bit. I can open my Reader X program (ver.10.1.3). I also have Adobe Acrobat X Pro installed on this PC - which now will not open at all - it was working previously. If I right click a PD
-
Changing security settings in iMac.
I had this error report come up when installing an Apoggee Duet manual on an external bootable drive with Mt Lion on it.Here is what it says: "Your security preferences only allows installation from mac app store & identified developers". How do I ch
-
Why can't I load any new video on my Ipad? It shows that I have used 27.2GB and have 609MB remaining even though everything listed including photos and camera only adds up to 7GB. I purchased additonal storage on Icloud and have 24GB left. I am getti
-
How can I add new background on iweb?
Dear all, somebody knows how can I add new backgroungs on iweb? and also how can I add my own themes? Cheers