Transfer an internal table with non char data type to an application server
Here is a part of my code. lv_string variable was type string initially but i got an error Not mutually convertible in a Unicode Program. I changed it to type ty_afko. Now the program works but the data it puts out has just a bunch of #####. I cannot make all value in the internal table type char because then my select statement is giving errors.. Please help...
Type: BEGIN OF ty_afko,
rsnum LIKE afko-rsnum, " Number of reservation
aprio LIKE afko-aprio, " Order Priority
maufnr LIKE afko-maufnr, " Number of superior order
lead_aufnr LIKE afko-lead_aufnr, " Leading order in current processing
END OF ty_afko.
data: gt_afko TYPE STANDARD TABLE OF ty_afko INITIAL SIZE 0,
wa_afko TYPE ty_afko,
select rsnum aprio maufnr lead_aufnr
from afko into table gt_afko.
IF gv_error = 'X'.
EXIT.
ELSE.
<b>DATA: Lv_string type ty_afko.</b>
loop at gt_afko into wa_afko.
clear lv_string.
<b> move wa_afko to lv_string.</b>
perform f_transfer_dataset using gc_f_afko lv_string changing gv_error.
endloop.
endif.
FORM f_transfer_dataset USING p_file
p_data
CHANGING p_error TYPE c.
Data: lv_file(25) type c.
CONCATENATE gc_path p_file INTO lv_file.
TRANSFER p_data TO lv_file.
ENDFORM. "F_TRANSFER_DATASET
The key is to create another empty structure with fields of type c.
TYPES: BEGIN OF ty_resb,
bdter TYPE RESB-BDTER, " This field is type d
bdmng type resb-bdmng, " This field is type p with 3 decimals - total 14
END OF ty_resb,
BEGIN OF ty_resbstr, " This structure is the same as above but the field types will be char.
bdter(10),
bdmng(14),
END OF ty_resbstr.
DATA: gt_resb TYPE STANDARD TABLE OF ty_resb,
wa_resb TYPE ty_resb,
structure type ty_resbstr. " Empty fields with the same structure as the work area.
SELECT bdter bdmng FROM resb INTO corresponding fields of TABLE gt_resb.
open dataset pfile for output in text mode encoding default.
loop at gt_resb into wa_resb.
clear gv_string.
move-corresponding wa_resb to gv_string.
perform f_transfer_dataset using gc_f_resb gv_string.
endloop.
FORM f_transfer_dataset USING p_file p_data.
TRANSFER p_data TO lv_file.
ENDFORM.
Similar Messages
-
Building a table with a string data type
I am using the Build Table function and I would like to be able to label my columns on the first iteration with a string data type, which doesn't seem to be an acceptable signal for the Build Table function. However, the express table is located under "text indicators" on the front panel, so it seems like there should be a way to do this..
Ah, the "Build Table" Express VI. I hate Express VIs.
That Express VI is nothing more than a really complicated way of creating a 2D array of strings. The Express VI has no inputs for the row and column headers, so you need to add them in yourself. The same would be true for a regular table control/indicator. Here's what you need to do:
Right-click on the table indicator and select Visible Items -> Column Headers.
Right-click on the table indicator and select Create -> Property Node -> Column Header Strings[]. LabVIEW will attach a property node to the cursor and switch to the block diagram. Plop down the property node on the block diagram.
Right-click on the property node on the block diagram and select "Change All to Write".
Right-click on the property node and select "Create -> Constant". This will give you an array of strings, and you can enter the column headers in each array element.
Wire the array to the property node.
Connect the property node to the Build Table Express VI using the error clusters.
Message Edited by smercurio_fc on 07-02-2008 09:25 AM
Attachments:
Example_VI_BD6.png 3 KB -
Passing internal table with a field of type string to & from BAPI
Hello ABAP gurus,
I have a simple BAPI which has to send back an internal table.
Internal table structure is as follows
DATA: BEGIN OF itab OCCURS 0,
config_id(8),
blobdata like zstring,
END OF itab.
where zstring is a string of variable length.
When I try to activate the BAPI I get a message
"itab" must be a flat structure. You cannot use internal tables, strings, references or structures as components.
However, just for testing, I changed blobdata to type of char and I can successfully activate and use the BAPI.
But, our requirement is to pass a string of variable length.
How can I resolve this issue? I have searched sdn and other blogs but didn't help so far.
Any feedback on this will be highly appreciated.
Thanks
RamHi Prasad ,
Try this way :
Acc to your requirement ,create a structure with a parameter and a string , create a table type for that structure .
use that table type in the changing parameter as you need that bapi to accept and return a table .
for the below example , ZTEST_05 is a structure , ZTT_TEST_05 is a table type of ZTEST_05 .
ZTEST_05 has got 2 fields , one is a param of type char(8) and another is a string of type STRING .
I created the below mentioned BAPI and I was able to activate it without any errors .
FUNCTION ZTEST_BAPI_ITAB_01.
""Local Interface:
*" IMPORTING
*" VALUE(BAPI_P1) TYPE ZTEST_05
*" CHANGING
*" VALUE(BAPI_CP1) TYPE ZTT_TEST_05
ENDFUNCTION.
Revert if any issues .
Regards,
Ranjita -
Agg tables with non-Sum aggregation type
Situation: We have a fact called Ending Cash Balance that is non-additive across time. Each month, it shows the cash on hand at the end of the month. So our aggregation method is "Last" for the Time dimension (i.e. the value for Q1 = March, value for year = Dec), and "Sum" for all Other dimensions.
Using the Aggregation Wizard, we've built an agg table that contains the correct values for Ending Cash Balance (abbrev. ECB), rolled up along all levels properly.
However, our Answers query will NOT use that agg table when querying ECB. In fact, our logical table contains ECB (non-additive along Time) and Capital Spending (additive along time, so the agg method is Sum). When we query Capital Spending by month, the query hits the agg table. When we query ECB by month, the query refuses to hit the agg table. The only difference between the two fact columns is the aggregation method along the Time dimension.
The agg table is perfectly good, but the query will not use it for the fact that has a "non-sum" aggregation method. Any ideas?Mark, OBIEE repositories from ver 10.1.3.x allows for an flag "Data is Dense" to be set up in the aggregation tab of the measure (fact) in question. Please check if this allows you to get the last along time calculation to occur based on results taken from Aggregate table instead of base level fact table. Read up help on this option also.
With this option turned on, I expect measure to get aggregated as follows:
Base level Fact: Day level
Aggregate Table: Month level (say)
Query at Month level => should fetch results from Agg table (sum along other dimensions as reqd)
Query at Quarter level => should fetch results from Agg table (sum along all other dimensions except time as reqd) and choose the last month of Quarter for showing value at Quarter level.
Also experiment with using Aggregation method in Answers (not rpd) as "Server (default)" if using in pivot. Sometimes the results are correct from db to rpd (mid tier) but the front end aggregation spoils the report.
HTH
Shankar -
Internal table with and with out work area.
Hi all,
in performance terms which one is better 1) internal table with header line or 2) itab w/o header line and explicit work area for that itab.
which one is better and how?
Thanks in advance.
SAIHai Sai Ram
Internal Table with header Line Improves the Performence
1)
TABLES CUSTOMERS.
Defining an internal table with header line
DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100
WITH HEADER LINE.
Reading all entries of the database table into the internal table
SELECT * FROM CUSTOMERS INTO TABLE ALL_CUSTOMERS.
2)
Check the following code for the Difference
REPORT ZWRITEDOC LINE-SIZE 124 NO STANDARD PAGE HEADING.
TABLES: DD03L, "
DD04T, "R/3-DD: Textos de los elementos de datos
DD02T. "R/3-DD: Textos de tablas SAP
Tabla temporal con las lineas de cada tabla
DATA: BEGIN OF I_LINEAS OCCURS 100,
LINEA(80),
END OF I_LINEAS.
Tabla con las caracteristicas de la tabla
DATA: BEGIN OF I_TABLA OCCURS 100,
CAMPO(12),
TIPO(4),
LONG(5) TYPE I,
REF(20),
DESCR(40),
END OF I_TABLA.
DATA: D_NOMBRE(80),
D_DESCRIPCION(80).
DATA : BEGIN OF SOURCE OCCURS 1000,
LINE(72),
END OF SOURCE.
PARAMETERS: PROGRAM LIKE SY-REPID DEFAULT SY-REPID.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'GRAB'.
PERFORM GRABAR.
ENDCASE.
START-OF-SELECTION.
SET PF-STATUS 'ZSTATUS1'.
READ REPORT PROGRAM INTO SOURCE.
DATA L_GRAB.
CLEAR L_GRAB.
LOOP AT SOURCE.
translate source to upper case.
IF L_GRAB IS INITIAL.
D_DESCRIPCION = I_LINEAS-LINEA.
ENDIF.
I_LINEAS = SOURCE.
SEARCH I_LINEAS-LINEA FOR 'BEGIN OF'.
IF SY-SUBRC = 0.
SEARCH I_LINEAS-LINEA FOR 'DATA'.
IF SY-SUBRC = 0.
L_GRAB = 'X'.
FREE I_LINEAS.
ENDIF.
ENDIF.
IF L_GRAB = 'X'.
I_LINEAS = SOURCE.
APPEND I_LINEAS.
SEARCH I_LINEAS-LINEA FOR 'END OF'.
IF SY-SUBRC = 0.
CLEAR L_GRAB.
PERFORM PROCESAR_FICHERO.
PERFORM IMPRIMIR.
FREE I_LINEAS.
CLEAR D_DESCRIPCION.
ENDIF.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'WITH HEADER LINE'.
IF SY-SUBRC = 0.
APPEND I_LINEAS.
PERFORM PROCESAR_FICHERO.
PERFORM IMPRIMIR.
ENDIF.
ENDLOOP.
*& Form GRABAR
Graba el fichero en c:\temp\p.rtf y lo abre con word.
FORM GRABAR.
CALL FUNCTION 'LIST_DOWNLOAD'
EXPORTING
LIST_INDEX = SLIST_INDEX_DEFAULT
METHOD = 'RTF'
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'EXECUTE_WINWORD'
EXPORTING
I_FILE = 'C:\TEMP\P.RTF'
EXCEPTIONS
OTHERS = 1.
ENDFORM. " GRABAR
*& Form PROCESAR_FICHERO
FORM PROCESAR_FICHERO.
DATA: L_AUX1(80),
L_AUX2(80).
FREE I_TABLA.
LOOP AT I_LINEAS.
CLEAR I_TABLA.
translate i_lineas-linea to upper case.
SEARCH I_LINEAS-LINEA FOR 'BEGIN OF'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'BEGIN OF' INTO L_AUX1 D_NOMBRE.
SPLIT D_NOMBRE AT 'OCCURS' INTO D_NOMBRE L_AUX1.
ENDIF.
SEARCH I_LINEAS-LINEA FOR '('.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT '(' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-CAMPO = L_AUX1.
SPLIT L_AUX2 AT ')' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
IF L_AUX1 CO '0123456789 '.
I_TABLA-LONG = L_AUX1.
ENDIF.
I_TABLA-TIPO = 'CHAR'.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'LIKE'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'LIKE' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-CAMPO = L_AUX1.
SPLIT L_AUX2 AT ',' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-REF = L_AUX1.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'TYPE'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'TYPE' INTO L_AUX1 L_AUX2.
IF I_TABLA-CAMPO IS INITIAL.
CONDENSE L_AUX1.
I_TABLA-CAMPO = L_AUX1.
ENDIF.
SPLIT L_AUX2 AT ',' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
CASE L_AUX1.
WHEN 'I'.
I_TABLA-TIPO = 'INT'.
I_TABLA-LONG = 4.
WHEN 'C'.
I_TABLA-TIPO = 'CHAR'.
WHEN 'N'.
I_TABLA-TIPO = 'NUMC'.
WHEN 'T'.
I_TABLA-TIPO = 'TIME'.
I_TABLA-LONG = 8.
WHEN OTHERS.
I_TABLA-TIPO = L_AUX1.
ENDCASE.
ENDIF.
SEARCH I_LINEAS-LINEA FOR '"'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT '"' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX2.
I_TABLA-DESCR = L_AUX2.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'INCLUDE STRUCTURE'.
IF SY-SUBRC = 0.
SPLIT I_LINEAS-LINEA AT 'INCLUDE STRUCTURE' INTO L_AUX1 L_AUX2.
SPLIT L_AUX2 AT '.' INTO L_AUX1 L_AUX2.
CONDENSE L_AUX1.
I_TABLA-CAMPO = 'INCLUDE STR'.
I_TABLA-REF = L_AUX1.
ENDIF.
SEARCH I_LINEAS-LINEA FOR 'WITH HEADER LINE'.
IF SY-SUBRC = 0.
IF NOT I_LINEAS-LINEA CA '"'.
SPLIT I_LINEAS-LINEA AT 'OCCURS' INTO L_AUX1 L_AUX2.
IF SY-SUBRC = 0.
SPLIT L_AUX1 AT 'LIKE' INTO L_AUX1 L_AUX2.
IF SY-SUBRC = 0.
CONDENSE L_AUX2.
IF NOT L_AUX2 IS INITIAL.
I_TABLA-CAMPO = '...'.
I_TABLA-TIPO = 'TABI'.
I_TABLA-REF = L_AUX2.
SELECT SINGLE * FROM DD02T
WHERE TABNAME = L_AUX2
AND DDLANGUAGE = SY-LANGU.
IF SY-SUBRC = 0.
I_TABLA-TIPO = 'TABE'.
I_TABLA-DESCR = DD02T-DDTEXT.
ENDIF.
IF L_AUX1 CA ':'.
SPLIT L_AUX1 AT 'DATA:' INTO L_AUX1 L_AUX2.
ELSE.
SPLIT L_AUX1 AT 'DATA' INTO L_AUX1 L_AUX2.
ENDIF.
D_NOMBRE = L_AUX2.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
IF NOT I_TABLA-CAMPO IS INITIAL.
APPEND I_TABLA.
ENDIF.
ENDLOOP.
LOOP AT I_TABLA WHERE NOT REF IS INITIAL.
SPLIT I_TABLA-REF AT '-' INTO L_AUX1 L_AUX2.
SELECT SINGLE * FROM DD03L
WHERE TABNAME = L_AUX1
AND FIELDNAME = L_AUX2.
IF SY-SUBRC = 0.
I_TABLA-TIPO = DD03L-DATATYPE.
I_TABLA-LONG = DD03L-INTLEN.
IF I_TABLA-DESCR IS INITIAL.
SELECT SINGLE * FROM DD04T
WHERE ROLLNAME = DD03L-ROLLNAME
AND DDLANGUAGE = SY-LANGU.
IF SY-SUBRC = 0.
I_TABLA-DESCR = DD04T-DDTEXT.
ENDIF.
ENDIF.
MODIFY I_TABLA.
ENDIF.
ENDLOOP.
ENDFORM. " PROCESAR_FICHERO
*& Form IMPRIMIR
FORM IMPRIMIR.
DATA L_AUX(80).
FORMAT COLOR COL_NORMAL INTENSIFIED ON.
ULINE AT 1(80).
WRITE: / SY-VLINE,
(76) D_NOMBRE CENTERED,
SY-VLINE.
SPLIT D_DESCRIPCION AT '*' INTO L_AUX D_DESCRIPCION.
WRITE: / SY-VLINE,
(76) D_DESCRIPCION CENTERED,
SY-VLINE.
NEW-LINE.
ULINE AT 1(80).
DETAIL.
FORMAT COLOR OFF.
WRITE: /
SY-VLINE,
(10) 'CAMPO',
SY-VLINE,
(4) 'TIPO',
SY-VLINE,
(4) 'LONG',
SY-VLINE,
(16) 'REFERENCIA',
SY-VLINE,
(30) 'DESCRIPCION',
SY-VLINE.
NEW-LINE.
ULINE AT 1(80).
DETAIL.
LOOP AT I_TABLA.
WRITE: /
SY-VLINE,
(10) I_TABLA-CAMPO,
SY-VLINE,
I_TABLA-TIPO,
SY-VLINE,
(4) I_TABLA-LONG,
SY-VLINE,
(16) I_TABLA-REF,
SY-VLINE,
(30) I_TABLA-DESCR,
SY-VLINE.
ENDLOOP.
NEW-LINE.
ULINE AT 1(80).
SKIP 2.
ENDFORM. " IMPRIMIR
Thanks & regards
Sreeni -
Create dynamic internal table with dynamic structure
I have an internal table itab1 that have 12 amount fields from period1 thru period12. I need to create a dynamic table with dynamic structure for the period column if the total amount of each column is > 0. Any idea on how to do that?
For example if my itab1 has 20 rows and the sum of period1 = 35, sum of period2 = 0, sum of period3 = 5, sum of period4 =0, sum of period5 = 2 then I need to create a dynamic structure for the field column that have the total > 0, i.e structure struct1 have field period1, period3 and period5 only. Then I will need to load the data to itab2 from itab1. Can someone help.
Thanks. I am on 4.7 and will upgrade to ERP 6.0 soon.go throgh this....
REPORT yusmm_text1 NO STANDARD PAGE HEADING
LINE-SIZE 199.
T A B L E S
TABLES: MARA,
MAKT,
THEAD.
GLOBAL TYPE-POOLS
TYPE-POOLS : SLIS.
GLOBAL TYPES
TYPES : BEGIN OF TP_FINAL,
MATNR TYPE MARA-MATNR,
BEGRU TYPE MARA-BEGRU,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
SPRAS TYPE MAKT-SPRAS,
LTXT(2000) TYPE C ,
SRNO TYPE N ,
END OF TP_FINAL.
TYPES : BEGIN OF TP_T002,
SPRAS TYPE T002-SPRAS,
LAISO TYPE T002-LAISO,
SRNO TYPE N ,
END OF TP_T002.
TYPES : BEGIN OF TP_MARA_MAKT,
MATNR TYPE MARA-MATNR,
BEGRU TYPE MARA-BEGRU,
MTART TYPE MARA-MTART,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END OF TP_MARA_MAKT.
Types: BEGIN OF tp_matnr,
matnr TYPE mara-matnr,
END OF tp_matnr.
GLOBAL ELEMENTARY VARIABLES
DATA : gv_date TYPE sy-datum.
DATA : gv_repid TYPE sy-repid.
DATA : g_var1(10) TYPE C.
DATA : gv_index TYPE sy-tabix.
DATA: gv_strg TYPE string,
gv_strg1(2000) TYPE C.
DATA : gv_lang TYPE sy-langu.
DATA : g_v(3) TYPE N .
DATA : gv_lines(3) TYPE N .
DATA : gv_var(3) TYPE N .
DATA : gv_var1(3) TYPE N.
DATA: gv_str TYPE STRING.
DATA: gv_str1 TYPE STRING.
DATA : gv_li TYPE I,
gv_lit TYPE I,
gv_lin TYPE I.
DATA: g_var11(3) TYPE N,
gv_li1(3) TYPE N,
g_var2(3) TYPE N.
DATA : gv_i1 TYPE I.
DATA : gv_i TYPE I.
DATA: gl_lenght TYPE I.
GLOBAL STRUCTURES
DATA: T_NEWTABLE TYPE REF TO DATA,
T_NEWLINE TYPE REF TO DATA,
T_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
T_FLDCAT TYPE LVC_T_FCAT,
WA_IT_FLDCAT TYPE LVC_S_FCAT,
WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV,
WA_COLNO(2) TYPE N,
WA_FLNAME(5) TYPE C,
L_LT TYPE SLIS_LAYOUT_ALV.
GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
DATA : IG_MARA_MAKT TYPE STANDARD TABLE OF TP_MARA_MAKT,
WG_MARA_MAKT TYPE TP_MARA_MAKT.
DATA : IG_T002 TYPE STANDARD TABLE OF TP_T002,
WG_T002 TYPE TP_T002.
DATA : IG_FINAL TYPE STANDARD TABLE OF TP_FINAL,
WG_FINAL TYPE TP_FINAL.
data : IG_MATNR TYPE STANDARD TABLE OF TP_MATNR WITH HEADER LINE,
WG_MATNR TYPE TP_MATNR.
DATA:BEGIN OF IG_THEAD OCCURS 0.
INCLUDE STRUCTURE THEAD .
DATA: END OF IG_THEAD.
DATA:BEGIN OF IG_TLINE OCCURS 0.
INCLUDE STRUCTURE TLINE .
DATA:END OF IG_TLINE.
FIELD-SYMBOLS
FIELD-SYMBOLS: <T_DYNTABLE> TYPE STANDARD TABLE,"Dynamic internal
"tablename
<FS_DYNTABLE>, "Field symbol to create work area
<FS_FLDVAL> TYPE ANY. " Field symbol to assign values
COMPULSORY
FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,
<FS_DATA1> TYPE REF TO DATA,
<FS_2> TYPE STANDARD TABLE,
<FS_22> TYPE STANDARD TABLE,
<FS_1>,
<FS_11>,
<F>,
<FA>,
<LWA_LINE_WA>,
<LWA_LINE_WA1>.
------- Create Dyn Table From FC
DATA: LT_DATA TYPE REF TO DATA,
LT_DATA1 TYPE REF TO DATA,
LWA_LINE TYPE REF TO DATA,
LWA_LINE1 TYPE REF TO DATA,
LI_FIELD_CAT TYPE LVC_T_FCAT,
LWA_FIELD_CAT TYPE LVC_S_FCAT.
PARAMETERS & SELECT-OPTIONS
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_SPRAS FOR MAKT-SPRAS NO INTERVALS DEFAULT 'EN'
OBLIGATORY ,
S_MATNR FOR MARA-MATNR,
S_MTART FOR MARA-MTART.
PARAMETERS: GP_SIZE TYPE I DEFAULT '200'.
SELECTION-SCREEN : END OF BLOCK B1.
INITIALIZATION
INITIALIZATION.
gv_repid = sy-repid.
gv_date = sy-datum.
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
IF GP_SIZE < 0.
MESSAGE E002(00).
ENDIF.
IF GP_SIZE > 50000.
MESSAGE W130(26) WITH TEXT-004.
SET CURSOR FIELD 'gp_size'.
ENDIF.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM FIELDCAT.
PERFORM LAYOUT.
PERFORM DATA_FETCH.
PERFORM READ_DATA_TO_FINAL.
SORT ig_final BY matnr spras.
gv_lin = gv_li.
gv_li = gv_li - 2.
LOOP AT ig_final INTO wg_final.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'Material Number'.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'Authorization Group'.
g_VAR11 = wg_final-srno + 2.
gv_li1 = gv_li1 + 2.
MOVE : g_var11 TO gv_i1.
ASSIGN COMPONENT g_var11 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'MatDesc'.
g_var2 = g_var11 + gv_lines.
ASSIGN COMPONENT g_var2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = 'BasicData'.
APPEND <LWA_LINE_WA1> TO <FS_22>.
EXIT.
ENDLOOP.
LOOP AT ig_final INTO wg_final.
AT NEW matnr.
gv_index = sy-tabix.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-matnr.
ENDAT.
AT NEW MATNR.
GV_INDEX = SY-TABIX.
ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-matnr.
ENDAT.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-begru.
ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-begru.
gv_var = wg_final-srno + 2.
gv_li = gv_li + 2.
MOVE : gv_var TO gv_i.
ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-maktx.
ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-maktx.
gv_var1 = gv_var + gv_lines .
ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
<F> = wg_final-ltxt.
ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
<FA> = wg_final-ltxt.
AT END OF matnr.
APPEND <LWA_LINE_WA> TO <FS_2>.
CLEAR <LWA_LINE_WA>.
ENDAT.
AT END OF matnr.
APPEND <LWA_LINE_WA1> TO <FS_22>.
CLEAR <LWA_LINE_WA1>.
ENDAT.
ENDLOOP.
PERFORM display..
*& Form data_fetch
text
--> p1 text
<-- p2 text
FORM DATA_FETCH .
SELECT matnr
from mara up to gp_size rows
appending corresponding fields of table ig_matnr
where matnr in s_matnr
and mtart in s_mtart.
loop at ig_matnr.
SELECT MARA~MATNR
MARA~BEGRU
MARA~MTART
MAKT~SPRAS
MAKT~MAKTX FROM MARA INNER JOIN MAKT
ON MARAMATNR = MAKTMATNR
appending corresponding fields of TABLE ig_mara_makt UP TO GP_SIZE
ROWS
WHERE makt~spras IN s_spras
AND mara~matnr IN s_matnr
AND mara~mtart IN s_mtart
AND mara~matnr EQ ig_matnr-matnr.
endloop.
IF sy-subrc = 0.
SORT ig_mara_makt.
ENDIF.
ENDFORM. " data_fetch
*& Form read_data_to_final
text
--> p1 text
<-- p2 text
FORM READ_DATA_TO_FINAL .
LOOP AT ig_mara_makt INTO wg_mara_makt .
wg_final-MATNR = wg_mara_makt-MATNR.
wg_final-BEGRU = wg_mara_makt-BEGRU.
wg_final-MTART = wg_mara_makt-MTART.
wg_final-SPRAS = wg_mara_makt-SPRAS.
wg_final-MAKTX = wg_mara_makt-MAKTX.
READ TABLE ig_t002 INTO wg_t002 WITH KEY spras = wg_final-spras.
IF sy-subrc = 0.
wg_final-srno = wg_t002-srno.
ENDIF.
CLEAR ig_thead[].
ig_thead-TDOBJECT = 'MATERIAL'.
ig_thead-TDNAME = wg_final-matnr.
ig_thead-TDID = 'GRUN'.
ig_thead-TDSPRAS = wg_final-spras.
CALL FUNCTION 'TEXT_READ'
EXPORTING
I_HEADER = IG_THEAD
I_READONLY = 'X'
IMPORTING
E_HEADER = IG_THEAD
TABLES
T_LINES = IG_TLINE[]
EXCEPTIONS
NOTFOUND = 1.
IF sy-subrc EQ 0.
LOOP AT ig_tline.
gv_strg = ig_tline-tdline.
IF gv_strg1 <> ' '.
CONCATENATE gv_strg1 ';' gv_strg INTO gv_strg1.
ELSE.
gv_strg1 = gv_strg.
ENDIF.
ENDLOOP.
wg_final-ltxt = gv_strg1.
APPEND wg_final TO ig_final.
CLEAR wg_final.
gv_strg1 = ' '.
ELSE.
APPEND wg_final TO ig_final.
ENDIF.
ENDLOOP.
ENDFORM. " read_data_to_final
" read_data_to_final
*& Form layout
text
--> p1 text
<-- p2 text
FORM LAYOUT .
CLEAR L_LT.
L_LT-ZEBRA = 'X'.
L_LT-COLWIDTH_OPTIMIZE = 'X'.
L_LT-WINDOW_TITLEBAR = 'MATERIAL DETAILS'.
ENDFORM. " layout
*& Form fieldcat
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
SELECT SPRAS
LAISO FROM t002 INTO CORRESPONDING FIELDS OF TABLE ig_t002
WHERE spras IN s_spras.
DESCRIBE TABLE ig_t002 LINES gv_lines.
LOOP AT ig_t002 INTO wg_t002.
g_v = g_v + 1.
Wg_t002-srno = g_v.
MODIFY ig_t002 FROM wg_t002 TRANSPORTING SRNO.
ENDLOOP.
LOOP AT ig_t002 INTO wg_t002.
CLEAR WA_IT_FLDCAT.
MOVE SY-INDEX TO WA_COLNO.
CONCATENATE 'MD-' wg_t002-LAISO
WA_COLNO
INTO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
WA_IT_FLDCAT-INTLEN = 250.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
APPEND WA_IT_FLDCAT TO T_FLDCAT.
CLEAR wg_t002.
ENDLOOP.
LOOP AT ig_t002 INTO wg_t002.
CLEAR WA_IT_FLDCAT.
MOVE SY-INDEX TO WA_COLNO.
CONCATENATE 'BD-' wg_t002-LAISO
WA_COLNO
INTO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
WA_IT_FLDCAT-INTLEN = 250.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
APPEND WA_IT_FLDCAT TO T_FLDCAT.
CLEAR wg_t002.
ENDLOOP.
MOVE 'MATNR' TO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = 'Material No'.
WA_IT_FLDCAT-INTLEN = 18.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 1.
MOVE 'BEGRU' TO WA_FLNAME.
WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
WA_IT_FLDCAT-DATATYPE = 'CHAR'.
WA_IT_FLDCAT-SELTEXT = 'Authorization Group'.
WA_IT_FLDCAT-INTLEN = 4.
WA_IT_FLDCAT-TABNAME = '<FS_2>'.
INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 2.
DESCRIBE TABLE T_FLDCAT LINES gv_li.
ASSIGN LT_DATA TO <FS_DATA>.
Creating the Dynamic Internal Table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue
IMPORTING
EP_TABLE = <FS_DATA> " Dynamic Internal Table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
Assign Dyn Table To Field Sumbol
ASSIGN <FS_DATA>->* TO <FS_1>.
Assigning the Internal Table TYPE ANY to Standard internal Table
ASSIGN <FS_1> TO <FS_2>.
Creating a Workarea
CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .
Assigning the Content to the workares as a Pointer
ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.
LOOP AT T_FLDCAT INTO WA_IT_FLDCAT.
WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.
WA_IT_FLDCAT1-TABNAME = WA_IT_FLDCAT-TABNAME.
WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-SELTEXT.
WA_IT_FLDCAT1-REF_TABNAME = 'MARC'.
APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.
CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.
ENDLOOP.
ASSIGN LT_DATA1 TO <FS_DATA1>.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = T_FLDCAT " Fieldcatalogue
IMPORTING
EP_TABLE = <FS_DATA1> " Dynamic Internal table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
Assign Dyn Table To Field Sumbol
ASSIGN <FS_DATA1>->* TO <FS_11>.
Assigning the Internal Table TYPE ANY to Standard internal Table
ASSIGN <FS_11> TO <FS_22>.
Creating a Workarea
CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .
Assigning the Content to the workares as a Pointer
ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.
ENDFORM. " fieldcat
*& Form show
text
--> p1 text
<-- p2 text
FORM Display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GV_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = L_LT
IT_FIELDCAT = T_FLDCAT1[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = <FS_2>
EXCEPTIONS
PROGRAM_ERROR = 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.
ENDFORM. " display
FORM PF_STATUS_SET USING RS_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'DISPLAY' .
ENDFORM. "PF_STATUS_SET
*& Form Name: user_command *
*& Form Desc: For Handling USER_COMMAND *
FORM USER_COMMAND USING IF_UCOMM TYPE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD.
CASE IF_UCOMM.
WHEN 'DOWNLOAD'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = ' '
DIAGNOSE_OBJECT = ' '
TEXT_QUESTION = 'Data download to excel'
TEXT_BUTTON_1 = 'Ja'(001)
ICON_BUTTON_1 = ' '
TEXT_BUTTON_2 = 'Nein'(002)
ICON_BUTTON_2 = ' '
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
USERDEFINED_F1_HELP = ' '
START_COLUMN = 25
START_ROW = 6
POPUP_TYPE =
IMPORTING
ANSWER =
TABLES
PARAMETER =
EXCEPTIONS
TEXT_NOT_FOUND = 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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\Material-Text.xls'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = 'X'
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = 'X'
IMPORTING
FILELENGTH = GL_LENGHT
TABLES
DATA_TAB = <FS_22>
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
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 GL_LENGHT NE 0.
MESSAGE S398(00) WITH 'DATA downloaded to EXCEL'.
ENDIF.
ENDCASE.
ENDFORM. "user_command
Thanks -
How to sort an internal table with a header line?
hi all,
i have declared table i_bseg type standard table of bseg with header line.
now i have populated data in i_bseg.
now i am sorting it by bukrs
ie i am writing sort i_bseg by bukrs.
before sorting all i_bseg-belnrs were populated...
but after sorting the contents of the i_bseg is changing.
some of the belnrs are getting deleted..
is there any special way to sort an internal table with header line...?hi,
<b>SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE].</b>
The statement sorts the internal table <itab> in ascending order by its key.<b> The statement always applies to the table itself, not to the header line</b>.
If you have an internal table with a structured line type that you want sort by a different key, you can specify the key in the SORT statement:
SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE]
BY <f1> [ASCENDING|DESCENDING] [AS TEXT]
<fn> [ASCENDING|DESCENDING] [AS TEXT].
<b>this is your sort statement: sort i_bseg by bukrs.
you try with this statement: sort i_bseg by bukrs STABLE.</b>
regards,
Ashokreddy -
What are the advantages of using an internal table with workarea
Hi,
can anyone tell me
What are the advantages of using an internal table with workarea
over an internal table with header line?
thnks in adv
regards
nagiHI,
Internal tables are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organising the contents of database tables according to users need.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
<b>Difference between Work Area and Header Line</b>
While adding or retrieving records to / from internal table we have to keep the record temporarily.
The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
e.g.
data: begin of itab occurs 10,
ab type c,
cd type i,
end of itab. " this table will have the header line.
data: wa_itab like itab. " explicit work area for itab
data: itab1 like itab occurs 10. " table is without header line.
The header line is a field string with the same structure as a row of the body, but it can only hold a single row.
It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table
1) The difference between
whih header line and with out heater line of internal table.
ex:-
a) Data : itab like mara occurs 0 with header line.
b) Data: itab like mara occurs 0.
-While adding or retrieving records to / from internal table we have to keep the record temporarily.
-The area where this record is kept is called as work area for the internal table.
-The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
-Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
a) Data : itab like mara occurs 0 with header line.
table is with header line
b) Data: itab like mara occurs 0.
table is without header line
2)work area / field string and internal table
which one is prefarable for good performance any why ?
-The header line is a field string with the same structure as a row of the body, but it can only hold a single row , whereas internal table can have more than one record.
In short u can define a workarea of an internal table which means that area must have the same structure as that of internal table and can have one record only.
Example code:
data: begin of itab occurs 10,
ab type c,
cd type i,
end of itab. " this table will have the header line.
data: wa_itab like itab. " explicit work area for itab
data: itab1 like itab occurs 10. " table is without header line.
Regards,
Padmam. -
Excel data transfer into SAP internal table with GUI_UPLOAD
hi all,
i m using SRM4 system and i wanted to develop one report which will upload data from excel and convert it into IT.
i know that many threads are posted on this topic.
but my requirement is slight different. in the system only one function module is available that is "GUI_UPLOAD" and we want that user shd not save file as tab delimited before calling this fm. instead, program shd take care of all these things...
please suggest something asap..
helpful ans will be rewarded..
thanks,
jigs.Dear Jigs,
Please go though the following lines of code:
D A T A D E C L A R A T I O N *
TABLES: ANEP,
BKPF.
TYPES: BEGIN OF TY_TABDATA,
MANDT LIKE SY-MANDT, " Client
ZSLNUM LIKE ZSHIFTDEPN-ZSLNUM, " Serial Number
ZASSET LIKE ZSHIFTDEPN-ZASSET, " Original asset that was transferred
ZYEAR LIKE ZSHIFTDEPN-ZYEAR, " Fiscal Year
ZPERIOD LIKE ZSHIFTDEPN-ZPERIOD, " Fiscal Period
ZSHIFT1 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 1
ZSHIFT2 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 2
ZSHIFT3 LIKE ZSHIFTDEPN-ZSHIFT1, " Shift No. 3
END OF TY_TABDATA.
Declaration of the Internal Table with Header Line comprising of the uploaded data.
DATA: BEGIN OF IT_FILE_UPLOAD OCCURS 0.
INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
DATA: END OF IT_FILE_UPLOAD.
S E L E C T I O N - S C R E E N *
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME,
BEGIN OF BLOCK B2 WITH FRAME.
PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B2,
END OF BLOCK B1.
E V E N T : AT S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = '.'
CHANGING
FILE_NAME = P_FNAME
EXCEPTIONS
MASK_TOO_LONG = 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.
E V E N T : S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Upload Excel file into Internal Table.
PERFORM UPLOAD_EXCEL_FILE.
Organize the uploaded data into another Internal Table.
PERFORM ORGANIZE_UPLOADED_DATA.
E V E N T : E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
*& Form UPLOAD_EXCEL_FILE
text
--> p1 text
<-- p2 text
FORM UPLOAD_EXCEL_FILE .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FNAME
I_BEGIN_COL = 1
I_BEGIN_ROW = 3
I_END_COL = 7
I_END_ROW = 32000
TABLES
INTERN = IT_FILE_UPLOAD
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.
ENDFORM. " UPLOAD_EXCEL_FILE
*& Form ORGANIZE_UPLOADED_DATA
text
--> p1 text
<-- p2 text
FORM ORGANIZE_UPLOADED_DATA .
SORT IT_FILE_UPLOAD BY ROW
COL.
LOOP AT IT_FILE_UPLOAD.
CASE IT_FILE_UPLOAD-COL.
WHEN 1.
WA_TABDATA-ZSLNUM = IT_FILE_UPLOAD-VALUE.
WHEN 2.
WA_TABDATA-ZASSET = IT_FILE_UPLOAD-VALUE.
WHEN 3.
WA_TABDATA-ZYEAR = IT_FILE_UPLOAD-VALUE.
WHEN 4.
WA_TABDATA-ZPERIOD = IT_FILE_UPLOAD-VALUE.
WHEN 5.
WA_TABDATA-ZSHIFT1 = IT_FILE_UPLOAD-VALUE.
WHEN 6.
WA_TABDATA-ZSHIFT2 = IT_FILE_UPLOAD-VALUE.
WHEN 7.
WA_TABDATA-ZSHIFT3 = IT_FILE_UPLOAD-VALUE.
ENDCASE.
AT END OF ROW.
WA_TABDATA-MANDT = SY-MANDT.
APPEND WA_TABDATA TO IT_TABDATA.
CLEAR: WA_TABDATA.
ENDAT.
ENDLOOP.
ENDFORM. " ORGANIZE_UPLOADED_DATA
In the subroutine --> ORGANIZE_UPLOADED_DATA, data are organized as per the structure declared above.
Regards,
Abir
Don't forget to award points * -
Internal table with Dynamic and Non dynamic fileds
Hi Experts,
How to get the internal table with Dynamic and Non-Dynamic Fields.
Could u please help me.
Thanks,
VarunHi,
Execute the below sample code or analyze it there is appropriate description provided.
*& Report ZTEST_PRM_DYN_ALV
REPORT ZTEST_PRM_DYN_ALV.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001.
parameters: p_flds(5) type c.
selection-screen end of block b1.
start-of-selection.
*build the dynamic internal table
perform build_dyn_itab.
*write 5 records to the alv grid
do 5 times.
perform build_report.
enddo.
*call the alv grid.
perform call_alv.
*Build_dyn_itab
form build_dyn_itab.
data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.
*Create fields .
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'name1'.
wa_it_fldcat-datatype = 'mara-matnr'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
*clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 6.
append wa_it_fldcat to it_fldcat .
enddo.
*Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
*Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
*Form build_report
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
do p_flds times.
index = sy-index.
*Set up fieldvalue
concatenate 'FLD' index into
fieldvalue.
condense fieldvalue no-gaps.
assign component index of structure <dyn_wa> to <fs1>.
<fs1> = fieldvalue.
enddo.
*Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.
*CALL_ALV
form call_alv.
data: wa_cat like line of alv_fldcat.
*clear wa_cat.
wa_cat-fieldname = 'matnr'.
wa_cat-seltext_s = sy-index.
wa_cat-outputlen = '10'.
append wa_cat to alv_fldcat.
do p_flds times.
clear wa_cat.
wa_cat-fieldname = sy-index.
wa_cat-seltext_s = sy-index.
wa_cat-outputlen = '6'.
append wa_cat to alv_fldcat.
enddo.
*Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = alv_fldcat
tables
t_outtab = <dyn_table>.
endform.
Hope this will help, reward if found usefull.
Cheers,
Ram. -
How to fill internal table with no data in debugging mode
Hi all,
I modified one existing program.Now I want to test it.I am not given test data.So in the middle of my debugging, I found that one internal table with no data.My problem is how to fill that internal table with few records in that debugging mode just as we change contents in debugging mode.If I want to proceed further means that internal table must have some records.
Please I dont know how to create test data so I am trying to create values temporarily in debugging mode only.
Thanks,
BalajiHi,
In the debugging do the following..
Click the Table button..
Double click on the internal table name..
Then in the bottom of the screen you will get the buttons like CHANGE, INSERT, APPEND, DELETE..
Use the APPEND button to insert records to the internal table..
Thanks,
Naren -
How to pass internal table with data in ABAP OO
Hi experts ,
Here is the problem...
I create a screen 100 and use the internal table to get data from database, and then press the button on screen 100 , it will call screen 200.
I use ABAP OO code in screen 200, and i want to keep the internal table with data that i get from the sceen 100 parts, but it seems that it just supports to create a new internal table and get data from database in ABAP OO. That means i need to create a new table to save the data in internal table ? Or there is any other solution something like exporting or memory id ...
ps . the internal table in screen 100 is declared in global area, the beginning of the code.
Please give me some advice, thanks a lot!
Regards ,
ClaireI have already know how to do, here is my code:
METHODS fill_tree importing itab2 like itab1.
CALL METHOD: me->fill_tree exporting itab2 = itab1.
In METHOD fill_tree,
declare
data: itab3 TYPE STANDARD TABLE OF itab,
itab3[] = itab1[].
It is useful to me, thanks a lot. -
Populating dynamic internal table with data
Hi,
I have an internal table with the data like the below
profit lineId amount
center
s21 70 1000
s21 80 1200
s22 70 800
In the above internal table the number of distinct lineIDs will be vary based on selection-screen creiteria.
So for this I build a fieldcatalog and dynamic internal table like the following
The data available in the above internal table should be placed into the dynamic internal table like the following.
profit
center LineID70 LineID80 .....etc
S21 1000 1200
S22 800
Can any one suggest how to proceed?
Thanks in advance
Nanda.Hi
This is my first ever reply so I hope this works or gives you some ideas.
DATA: l_idcount TYPE i,
l_idvalue LIKE itab2-amount.
*loop through the source internal table
LOOP AT itab1.
* increment count of id numbers in current profit center
l_idcount = l_idcount + 1.
* run through the amount fields in target internal table
DO ID_number TIMES VARYING l_idvalue
FROM itab2-LineID70 NEXT itab2-LineID80.
IF sy-index EQ l_idcount.
* change field value if id count same as field position
l_idvalue = itab1-amount.
ENDIF.
ENDDO.
AT END OF profit_center.
itab2-profit_center = itab1-profit_center.
APPEND itab2.
CLEAR l_idcount.
ENDAT.
ENDLOOP.
ID_number is the number of ids as a result of selection-screen criteria. -
Validate the data in the internal table with the date in selection screen
Hi all,
I want to validate the data in the internal table and get only the records with the input date in the selection screen.
The date is in the select options and please let me know how to get the records only if it satisfies the input date in the selection screen.
Regards,
ShalemFor Ex.
SELECT-OPTIONS: S_DATE FOR VBAK-VDATU
If you want to read one INTERNAL TABLE record
READ TABLE it_tab(internal table name) WHERE vdatu(date field name in the internal table) = s_date
If you want to move more then one
LOOP AT it_tab WHERE vdatu = s_date.
Take the field values in another table and append it. then end loop.
you will get the records which only have the date in select option..
If you want detail code give me internal table name and select option name i will write you the code.
regards
Yuvaram -
Filling Dyanamic Internal table with data
Hi All
I have a following requirement.
1.. I have internal table with 1 text field of length 1000, this is field with data uploaded from text file having data tab seprated
2. I have a dyanamic table in which i have to fill the using the above internal table splited by tab seprated into the corresponding fields of dyanamic table.
please suggest some solution for the above.
thanks
bobbyHi Martin,
But How to assign to dyanmic table fields if we are using
split t_intab at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into .
where t_intab has 1 field of lenth say 1000 in which data stored is tab seprated.
please find below my code, please check loop at t_intab
FUNCTION Z_TEXT.
""Local Interface:
*" IMPORTING
*" VALUE(I_EXPTABLE) TYPE LVC_T_FCAT
*" VALUE(I_DELIMETER) TYPE C DEFAULT 'T'
*" TABLES
*" T_INTAB
*" T_OUTTAB
Data declarations
DATA:
dtab TYPE REF TO data,
newstr2 TYPE REF TO cl_abap_typedescr,
tab_type1 TYPE REF TO cl_abap_tabledescr,
lref_ditab TYPE REF TO data,
lref_new_line TYPE REF TO data.
Field-Symbols declarations
FIELD-SYMBOLS:
<fs_dyn_tab1> TYPE ANY TABLE,
<fs_dyn_wa> TYPE ANY,
<fs> type any.
Create dynamic table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_exptable
IMPORTING
ep_table = lref_ditab
EXCEPTIONS
generate_subpool_dir_full = 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.
Assign the dynamic table reference to a field-symbol
ASSIGN lref_ditab->* TO <fs_dyn_tab1>.
Create a structure similar to the dynamic table created
CREATE DATA lref_new_line LIKE LINE OF <fs_dyn_tab1>.
ASSIGN lref_new_line->* TO <fs_dyn_wa>.
loop at t_intab.
if I_DELIMETER = 'T'.
split t_intab at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into .
endif.
endloop.
ENDFUNCTION.
thanks
bobby
Maybe you are looking for
-
Fast way to delete all voice memos?
My wife has a ton of Voice Memos. When you sync photos, the photos are imported into iTunes, then deleted from iPhone. When you sync Voice Memos, it brings in all the Voice Memos into iTunes on MacBook, but also leaves them on iPhone. So now she h
-
This mistake has confused the account somehow and actions done on one phone often have an effect on the other. I took these phones back to the dealer where they were purchased a few months ago, and they were able to correct some of the issues, but we
-
Design Limitation On ALL Santa Rosa MacBook Pros, 2.2 and 2.4 GHz
While searching the Internet for answers to my new $2500.00 MBP headphone (output jack) has audible hissing sounds I found several posts on Macrumors.com and macintouch.com to explain the design Limitation/Problem. To summarize: The Problem The issue
-
ARS (Remedy) Call BPEL Service
I am trying to get Remedy to call a BPEL webservice. Using HelloWorld example. I am unable to parse the wsdl from there tool. Has anyone found a workaround to this? Maybe saving the wsdl local and editing the file. Here is what a Remedy Web service l
-
Dear All How can I get Screen Area of Windows from Form. e.g. 800x600, 1024x768 pixels. Please Reply.