Runtime error in Dynamic internal table with AMOUNT and Quantity Fields..
Dear friends,
I am attempting write a dymanic Select Statement (with joins).
And the sleect query looks like this..
SELECT (LT_SEL_LIST)
INTO CORRESPONDING FIELDS OF
TABLE <DYN_TABLE>
FROM (LT_FROM_LIST)
WHERE (LT_WHERE3).
Here the into table is a dynamically created internal table..
which is created by ...this
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_OUTPUT2[]
IMPORTING
EP_TABLE = DY_TABLE.
the it_output2 contains the the fieldcatlog information of dynamically given fields :-
like:-
TABNAME
FIELDNAME
DATATYPE
LENG
INTTYPE
ROLLNAME
DECIMALS
REFTABLE
REFFIELD
i mean the internal table is constructed with reference to all the bove metadata.
Problem:- This query run fine with all the fields Except AMOUNT AND QUANTITY fields....
When the selection list contain VBAK-NETWR or MSEG-MENGE..It throws a runtime error.
"The data read during a SLECT access couldnt be inserted into the target field,either conversion is not supported for
the target field's type or the target field is too short."
after this I even tried to construct the dynamic table with CFILEDNAME and QFIELDNAME in the Fieldcatalog.
so now my fieldcatlog looks like this:---
LOOP AT IT_DD03L..
IF IT_DD03L-DATATYPE = 'CURR'.
TABLEFIELD-CFIELDNAME = IT_DD03L-FIELDNAME .
ENDIF.
IF IT_FIELDCAT3-DATATYPE = 'QUAN'.
TABLEFIELD-QFIELDNAME = IT_DD03L-FIELDNAME .
ENDIF.
TABLEFIELD-TABNAME = IT_DD03L-TABNAME.
TABLEFIELD-FIELDNAME = IT_DD03L-FIELDNAME.
TABLEFIELD-DATATYPE = IT_DD03L-DATATYPE.
TABLEFIELD-INTLEN = IT_DD03L-LENG.
TABLEFIELD-INTTYPE = IT_DD03L-INTTYPE .
TABLEFIELD-ROLLNAME = IT_DD03L-ROLLNAME.
TABLEFIELD-DECIMALS = IT_DD03L-DECIMALS.
TABLEFIELD-REF_TABLE = IT_DD03L-REFTABLE.
TABLEFIELD-REF_FIELD = IT_DD03L-REFFIELD.
APPEND TABLEFIELD.
CLEAR TABLEFIELD.
ENDLOOP.
Note:- this is a test code so ignore performance issues...
Please help me with some code ...to avoid the Runtime erorr.
Thanks,
jeevan.
Hi Jeevan,
Why are moving only few fields from DD03L table to your field catalog? Why don't you use move-corresponding? The following code works for me in ECC6.0.
data: it_dd03l type table of dd03l initial size 0,
ls_dd03l type dd03l,
lt_fldcat TYPE lvc_t_fcat,
ls_fldcat TYPE lvc_s_fcat,
ls_where(72) TYPE c,
lt_where LIKE TABLE OF ls_where,
lt_fld LIKE TABLE OF ls_where,
lt_data_dy TYPE REF TO data.
field-symbols: <ft_data> TYPE STANDARD TABLE.
select * into table it_dd03l from dd03l
where tabname = 'VBAK'
and ( fieldname = 'VBELN' or fieldname = 'NETWR' ).
check sy-subrc eq 0.
loop at it_dd03l into ls_dd03l.
move-corresponding ls_dd03l to ls_fldcat.
append ls_fldcat to lt_fldcat.
move ls_dd03l-fieldname to ls_where.
append ls_where to lt_fld.
if ls_dd03l-fieldname = 'VBELN'.
clear ls_where.
concatenate ls_dd03l-fieldname ' <> ''''' into ls_where.
append ls_where to lt_where.
endif.
endloop.
check not lt_fldcat is initial.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fldcat
IMPORTING
ep_table = lt_data_dy
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE no_configuration_data.
ENDIF.
ASSIGN lt_data_dy->* TO <ft_data>.
check sy-subrc eq 0.
select (lt_fld) from VBAK into corresponding fields of table
<ft_data>
where (lt_where).
Thanks
Bala
Similar Messages
-
MS SQL Server 2014: Error inserting into Temp table with index and identity field
In this thread, I mentioned a problem with SQL Server 2014:
SQL Server 2014: Bug with IDENTITY INSERT ON
The question was answered, it is a bug. To keep you informed on this issue, I open this discussion.
Problem:
The code below works perfectly fine on MS SQL Server 2008 R2 and MS SQL Server 2012, but gives an error every second time the proc is executed on MS SQL Server 2014. If I do not define any index on the temp table, the problem disappears. Defining the index
after the insert, does not help.
SET NOCOUNT ON
GO
IF EXISTS (SELECT 1 FROM sys.procedures WHERE name = 'usp_Test') DROP PROC dbo.usp_Test;
GO
CREATE PROC dbo.usp_Test AS
BEGIN
SET NOCOUNT ON
CREATE TABLE #Source(ID integer NOT NULL);
INSERT INTO #Source VALUES (1), (2), (3);
CREATE TABLE #Dest (ID integer IDENTITY(1,1) NOT NULL);
CREATE INDEX #IDX_Dest ON #Dest (ID);
PRINT 'Check if the insert might cause an identity crisis';
SELECT 'Source' AS SourceTable, * FROM #Source;
SELECT 'Destination' AS DestTable, * FROM #Dest;
SET IDENTITY_INSERT #Dest ON;
PRINT 'Do the insert';
INSERT INTO #Dest (ID) SELECT ID FROM #Source;
PRINT 'Insert ready';
SET IDENTITY_INSERT #Dest OFF;
SELECT * FROM #Dest;
DROP TABLE #Source;
DROP TABLE #Dest;
END;
GO
PRINT 'First execution of the proc, everything OK';
EXEC dbo.usp_Test;
PRINT '';
PRINT 'Second execution of the proc, the insert fails.';
PRINT 'Removing the index #IDX_Dest causes the error to disappear.';
EXEC dbo.usp_Test;
GO
DROP PROC dbo.usp_Test;
GOThere is some progress. Communication from a former Microsoft employee tells us this:
Shivendra Vishal
Engineer at Microsoft
I am no longer with MS, and I do not have code access, however from the public symbols, I could make out following:
sqlmin!SetidentI2I4+0x1f3:
000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] ds:00000000`00000000=????????????????
ExceptionAddress: 000007fef4d865d3 (sqlmin!SetidentI2I4+0x00000000000001f3)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 0000000000000000
Attempt to read from address 0000000000000000
This is a read AV and from registers it is clear that we were trying to move the value of location pointed by qword of register rax which is not valid:
rax=0000000000000000 rbx=0000000000000038 rcx=0000000000001030
rdx=0000000000000006 rsi=00000001f55def98 rdi=00000000106fd070
rip=000007fef4d865d3 rsp=00000000106fcf40 rbp=00000000106fcfe9
r8=0000000000000000 r9=00000001f55def60 r10=00000001f55defa0
r11=00000000106fcd20 r12=0000000000000000 r13=0000000000000002
r14=00000001f49c3860 r15=00000001f58c0040
iopl=0 nv up ei pl nz na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010206
The stack is:
# Child-SP RetAddr Call Site
00 00000000`106fcf40 000007fe`f30c1437 sqlmin!SetidentI2I4+0x1f3
01 00000000`106fd050 000007fe`f474e7ce sqlTsEs!CEsExec::GeneralEval4+0xe7
02 00000000`106fd120 000007fe`f470e6ef sqlmin!CQScanUpdateNew::GetRow+0x43d
03 00000000`106fd1d0 000007fe`f08ff517 sqlmin!CQueryScan::GetRow+0x81
04 00000000`106fd200 000007fe`f091cebe sqllang!CXStmtQuery::ErsqExecuteQuery+0x36d
05 00000000`106fd390 000007fe`f091ccb9 sqllang!CXStmtDML::XretDMLExecute+0x2ee
06 00000000`106fd480 000007fe`f08fa058 sqllang!CXStmtDML::XretExecute+0xad
07 00000000`106fd4b0 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
08 00000000`106fd5f0 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
09 00000000`106fd7e0 000007fe`f152cfaa sqllang!CSQLSource::Execute+0x86c
0a 00000000`106fd9b0 000007fe`f152c9e8 sqllang!CStmtExecProc::XretLocalExec+0x25a
0b 00000000`106fda30 000007fe`f152a1d8 sqllang!CStmtExecProc::XretExecExecute+0x4e8
0c 00000000`106fe1e0 000007fe`f08fa058 sqllang!CXStmtExecProc::XretExecute+0x38
0d 00000000`106fe220 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
0e 00000000`106fe360 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
0f 00000000`106fe550 000007fe`f0902267 sqllang!CSQLSource::Execute+0x86c
10 00000000`106fe720 000007fe`f0909087 sqllang!process_request+0xa57
11 00000000`106feee0 000007fe`f2bf49d0 sqllang!process_commands+0x4a3
12 00000000`106ff200 000007fe`f2bf47b4 sqldk!SOS_Task::Param::Execute+0x21e
13 00000000`106ff800 000007fe`f2bf45b6 sqldk!SOS_Scheduler::RunTask+0xa8
14 00000000`106ff870 000007fe`f2c136ff sqldk!SOS_Scheduler::ProcessTasks+0x279
15 00000000`106ff8f0 000007fe`f2c138f0 sqldk!SchedulerManager::WorkerEntryPoint+0x24c
16 00000000`106ff990 000007fe`f2c13246 sqldk!SystemThread::RunWorker+0x8f
17 00000000`106ff9c0 000007fe`f2c13558 sqldk!SystemThreadDispatcher::ProcessWorker+0x3ab
18 00000000`106ffa70 00000000`775d59ed sqldk!SchedulerManager::ThreadEntryPoint+0x226
19 00000000`106ffb10 00000000`7780c541 kernel32!BaseThreadInitThunk+0xd
1a 00000000`106ffb40 00000000`00000000 ntdll!RtlUserThreadStart+0x21
Unassembling the function:
000007fe`f4d8658e 4c8b10 mov r10,qword ptr [rax]
000007fe`f4d86591 4533e4 xor r12d,r12d
000007fe`f4d86594 410fb7d5 movzx edx,r13w
000007fe`f4d86598 4533c9 xor r9d,r9d
000007fe`f4d8659b 4533c0 xor r8d,r8d
000007fe`f4d8659e 488bc8 mov rcx,rax
000007fe`f4d865a1 4489642420 mov dword ptr [rsp+20h],r12d
000007fe`f4d865a6 41ff5230 call qword ptr [r10+30h]
000007fe`f4d865aa 8b5597 mov edx,dword ptr [rbp-69h]
000007fe`f4d865ad 4c8b10 mov r10,qword ptr [rax]
000007fe`f4d865b0 4489642438 mov dword ptr [rsp+38h],r12d
000007fe`f4d865b5 4489642430 mov dword ptr [rsp+30h],r12d
000007fe`f4d865ba 458d442401 lea r8d,[r12+1]
000007fe`f4d865bf 4533c9 xor r9d,r9d
000007fe`f4d865c2 488bc8 mov rcx,rax
000007fe`f4d865c5 c644242801 mov byte ptr [rsp+28h],1
000007fe`f4d865ca 4488642420 mov byte ptr [rsp+20h],r12b
000007fe`f4d865cf 41ff5250 call qword ptr [r10+50h]
000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] <=================== AV happened over here
000007fe`f4d865d6 488bc8 mov rcx,rax
000007fe`f4d865d9 4c8bf0 mov r14,rax
000007fe`f4d865dc ff5268 call qword ptr [rdx+68h]
000007fe`f4d865df 488d55e7 lea rdx,[rbp-19h]
000007fe`f4d865e3 4c8b00 mov r8,qword ptr [rax]
000007fe`f4d865e6 488bc8 mov rcx,rax
000007fe`f4d865e9 41ff5010 call qword ptr [r8+10h]
000007fe`f4d865ed f6450a04 test byte ptr [rbp+0Ah],4
I remember few issues with scan2ident function, I am not sure if they have fixed it however it appears that this is intoduced to SQL 2014 and we need help from MS to get this resolved as it needs code analysis.
It is not getting simulated for other versions of SQL apart from SQL 2014.
Also to add, interestingly, the value of rax is not visibly changed and it was successfully passed on to rcx, which has a valid value, so something should have changed the value of rax inside call to function using call qword ptr [r10+50h], and looking at this
it appears that it might be a list of functions and we are going at particular offset [50h]. So, bottom line is that the call to function qword ptr [r10+50h], should be changing something in rax, and debugging/analyzing this code might give us some more idea. -
Dynamic internal table with problem
Hi,
I have developed a program to update standard table. I am using dynamic internal table creation concept. But my dynamic internal table is having width only 1200 bytes. But many standard tables have more than that width. Do you have any input create dynamic internal table with more than 1200 bytes width..
Have a look at the error.
[http://3.bp.blogspot.com/_O5f8iAlgdNQ/SjYXTBpO92I/AAAAAAAAErI/Fs996_APHbE/s1600-h/error-792463.JPG|http://3.bp.blogspot.com/_O5f8iAlgdNQ/SjYXTBpO92I/AAAAAAAAErI/Fs996_APHbE/s1600-h/error-792463.JPG]
Expecting reply
Thanks
VenkatHi,
DATA: IT_TABSTRUC TYPE STANDARD TABLE OF DFIES INITIAL SIZE 0,
V_REF TYPE REF TO DATA,
V_I_AVL_CAT TYPE TABLE OF LVC_S_FCAT.
FIELD-SYMBOLS : <F_FS_DATA> TYPE STANDARD TABLE.
SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001
NO INTERVALS.
PARAMETERS: P_TABNAM TYPE X_TABNAME.
SELECTION-SCREEN:END OF BLOCK B1.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = p_tabnam
LANGU = SY-LANGU
TABLES
DFIES_TAB = IT_TABSTRUC
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3.
LOOP AT IT_TABSTRUC .
V_LS_AVL_CAT-FIELDNAME = IT_TABSTRUC -FIELDNAME.
V_LS_AVL_CAT-REF_TABLE = P_TABNAM.
V_LS_AVL_CAT-REF_FIELD = IT_TABSTRUC -FIELDNAME.
APPEND V_LS_AVL_CAT TO V_I_AVL_CAT.
ENDLOOP.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = V_I_AVL_CAT
IMPORTING
EP_TABLE = V_REF.
ASSIGN V_REF->* TO <F_FS_DATA>.
FREE V_REF.
SELECT * FROM (P_TABNAM) INTO CORRESPONDING
FIELDS OF TABLE <F_FS_DATA> .
Hope this resolves ur probs.... -
Creating Dynamic Internal table with a dynamic name
Hi,
I want to create dynamic internal tables with dynamic names.
For example:
Suppose I have a table with three fields.
1. Structure name
2.Fields
3.file
And the structure of the internal table is as follows:
TYPES:BEGIN OF table_type,
struct TYPE char70,
fields TYPE tt_type OCCURS 0,
File TYPE ttab_type OCCURS 0,
END OF table_type.
Suppose I have one record inside my internal table with struct as "STRUCTURE", fields have an internal table content of set of fields and File has some set of records.
Now I want to create dynamic internal table whose name will be "STRUCTURE" , the fields of the dynamic internal table structure[] will be as in fields, and the records will be as in File.
Like this if i have 100 records in my internal table then I have to create 100 dynamic internal table dynamically.
Can anyone suggest how to do this?
Edited by: Jjammy on Jul 22, 2009 7:52 AMHi,
Check the sample program and develop your program accordingly.
<font color=blue><pre>
REPORT ztest_notepad.
*& Declarations
*Type-pools
TYPE-POOLS:
slis.
*Types
TYPES:
ty_fcat TYPE lvc_s_fcat,
ty_fcatalog TYPE slis_fieldcat_alv.
*Work areas
DATA:
wa_fcat TYPE ty_fcat,
wa_fcatalog TYPE ty_fcatalog.
*Internal tables
DATA:
it_fcat TYPE STANDARD TABLE OF ty_fcat,
it_fcatalog TYPE STANDARD TABLE OF ty_fcatalog.
*Type reference
DATA:
it_dyn_tab TYPE REF TO data,
wa_newline TYPE REF TO data.
*Filed symbols
FIELD-SYMBOLS:
<gt_table> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY,
<l_field> TYPE ANY.
*Variables
DATA:
l_fieldname TYPE lvc_s_fcat-fieldname,
l_tabname TYPE lvc_s_fcat-tabname,
l_fieldtext TYPE lvc_s_fcat-seltext,
l_index TYPE char2.
"Selection-screen
PARAMETERS:
p_colms TYPE i.
*& start-of-selection.
START-OF-SELECTION.
PERFORM build_fieldcat.
PERFORM create_dynamic_table.
DO 20 TIMES.
DO p_colms TIMES.
l_index = sy-index.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
<l_field> = sy-index.
ENDDO.
INSERT <fs_dyntable> INTO TABLE <gt_table>.
ENDDO.
LOOP AT it_fcat INTO wa_fcat.
PERFORM fieldcatalog1 USING: wa_fcat-fieldname
wa_fcat-tabname
wa_fcat-seltext.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST_NOTEPAD'
it_fieldcat = it_fcatalog
TABLES
t_outtab = <gt_table>.
*& Form BUILD_FIELDCAT
FORM build_fieldcat .
CLEAR: l_fieldname,
l_tabname,
l_fieldtext,
l_index.
DO p_colms TIMES.
CLEAR l_index.
l_index = sy-index.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
CONCATENATE 'Field' l_index INTO l_fieldtext.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
ENDDO.
ENDFORM. " BUILD_FIELDCAT
*& Form CREATE_DYNAMIC_TABLE
FORM create_dynamic_table .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = it_dyn_tab.
ASSIGN it_dyn_tab->* TO <gt_table>.
Create dynamic work area and assign to FS
CREATE DATA wa_newline LIKE LINE OF <gt_table>.
ASSIGN wa_newline->* TO <fs_dyntable>.
ENDFORM. " CREATE_DYNAMIC_TABLE
*& Form FIELDCATALOG
FORM fieldcatalog USING field table f_txt.
wa_fcat-fieldname = field.
wa_fcat-tabname = table.
wa_fcat-seltext = f_txt.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM. " FIELDCATALOG
*& Form FIELDCATALOG1
FORM fieldcatalog1 USING field table f_txt.
wa_fcatalog-fieldname = field.
wa_fcatalog-tabname = table.
wa_fcatalog-seltext_m = f_txt.
APPEND wa_fcatalog TO it_fcatalog.
CLEAR wa_fcatalog.
ENDFORM. " FIELDCATALOG1 </pre>
</font>
Thanks
Venkat.O -
Create dynamic internal table with deep structure;cell coloring dynamic ALV
Hi,
My requirement is to do cell colouring for a dynamic ALV.
So I am creating a dynamic internal table using the following method.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcatalog[]
IMPORTING
ep_table = i_output.
But how do I define field COLORS which should be again an internal table ?
Is there any other way for cell colouring?
Putting my problem in another way:
How do I create a dynamic internal table with one field as another internal table.
Quick replies are highly appreciated.
Thanks,
Nisha Vengal.halo Nisha
Before building the display table . you can add the field in the feild catalog right . This display table gets generated from the field catalog right
1 Create a global structute say ZEXTEND_FIELDCAT
2 Have fields like STYLE type lvc_t_styl
COLOR type LVC_T_SCOL.
3 Now you have to extend ur fieldcatalog
l_fieldcat-fieldname = COLOR'.
l_fieldcat-ref_field = 'COLOR'.
l_fieldcat-ref_table = 'ZEXTEND_FIELDCAT'.
APPEND l_fieldcat TO lt_field_catalog.
CLEAR l_fieldcat. -
Dynamic internal table with repeated structure
Hi,
I have a requirement, in which I need to create a dynamic internal table with the below structure.
Dynamic Int. table structure: fld1 and fld2.
If another internal table (say int2), contains 3 records, then my final output table should contain the below structure.
Value 1 Value 2 Value3
fld1 fld2 fld1 fld2 fld1 fld2
If in case, the int2 table contains 10 records, then my final output table should contain the structure below.
Value 1 Value 2 ..... Value10
fld1 fld2 fld1 fld2 ..... fld1 fld2
Please advice on how to acquire this. Thanks in advance for your help.
Regards,
Swetha.You can do it...but it won't be table... it would be some thing like
itab
ref1-> strycture (field 1 field 2 field 3)
ref2-> structure (field1 field 4 )
ref3-> structure (field5 field7 )
say Define a internal table with a single field to hold a reference of Data
Go on creating Rows of different structures and storing the address into the table... you can use RTTS for same
Use the below link for RTTS (search on wiki for examples).
http://wiki.sdn.sap.com/wiki/display/ABAP/RuntimeTypeServices+%28RTTS%29 -
Internal table with Import and Export
Hi All,
Hi all
Please let me know the use of <b>Internal table with Import and Export parameters and SET/GET parameters</b>, on what type of cases we can use these? Plese give me the syntax with some examples.
Please give me detailed analysis on the above.
Regards,
PrabhuHi Prabhakar,
There are three types of memories.
1. ABAP MEMORY
2. SAP MEMORY
3. EXTERNAL MEMORY.
1.we will use EXPORT/ IMPORT TO/ FROM MEMORY-ID when we want to transfer between ABAP memory
2. we will use GET PARAMETER ID/ SET PARAMETER ID to transfer between SAP MEMORY
3. we will use EXPORT/IMPORT TO/FROM SHARED BUFFER to transfer between external memory.
ABAP MEMORY : we can say that two reports in the same session will be in ABAP MEMORY
SAP MEMORY: TWO DIFFERENT SESSIONS WILL BE IN SAP MEMORY.
for ex: IF WE CALL TWO DIFFERENT TRANSACTIONS SE38, SE11
then they both are in SAP MEMORY.
EXTERNAL MEMORY: TWO different logons will be in EXTERNAL MEMORY.
<b>Syntax</b>
To fill the input fields of a called transaction with data from the calling program, you can use the SPA/GPA technique. SPA/GPA parameters are values that the system stores in the global, user-specific SAP memory. SAP memory allows you to pass values between programs. A user can access the values stored in the SAP memory during one terminal session for all parallel sessions. Each SPA/GPA parameter is identified by a 20-character code. You can maintain them in the Repository Browser in the ABAP Workbench. The values in SPA/GPA parameters are user-specific.
ABAP programs can access the parameters using the SET PARAMETER and GET PARAMETER statements.
To fill one, use:
SET PARAMETER ID <pid> FIELD <f>.
This statement saves the contents of field <f> under the ID <pid> in the SAP memory. The code <pid> can be up to 20 characters long. If there was already a value stored under <pid>, this statement overwrites it. If the ID <pid> does not exist, double-click <pid> in the ABAP Editor to create a new parameter object.
To read an SPA/GPA parameter, use:
GET PARAMETER ID <pid> FIELD <f>.
This statement fills the value stored under the ID <pid> into the variable <f>. If the system does not find a value for <pid> in the SAP memory, it sets SY-SUBRC to 4, otherwise to 0.
To fill the initial screen of a program using SPA/GPA parameters, you normally only need the SET PARAMETER statement.
The relevant fields must each be linked to an SPA/GPA parameter.
On a selection screen, you link fields to parameters using the MEMORY ID addition in the PARAMETERS or SELECT-OPTIONS statement. If you specify an SPA/GPA parameter ID when you declare a parameter or selection option, the corresponding input field is linked to that input field.
On a screen, you link fields to parameters in the Screen Painter. When you define the field attributes of an input field, you can enter the name of an SPA/GPA parameter in the Parameter ID field in the screen attributes. The SET parameter and GET parameter checkboxes allow you to specify whether the field should be filled from the corresponding SPA/GPA parameter in the PBO event, and whether the SPA/GPA parameter should be filled with the value from the screen in the PAI event.
When an input field is linked to an SPA/GPA parameter, it is initialized with the current value of the parameter each time the screen is displayed. This is the reason why fields on screens in the R/3 System often already contain values when you call them more than once.
When you call programs, you can use SPA/GPA parameters with no additional programming overhead if, for example, you need to fill obligatory fields on the initial screen of the called program. The system simply transfers the values from the parameters into the input fields of the called program.
However, you can control the contents of the parameters from your program by using the SET PARAMETER statement before the actual program call. This technique is particularly useful if you want to skip the initial screen of the called program and that screen contains obligatory fields.
Reading Data Objects from Memory
To read data objects from ABAP memory into an ABAP program, use the following statement:
Syntax
IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.
This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO <g i > option, the data object <f i > in memory is assigned to the data object in the program with the same name. If you do use the option, the data object <f i > is read from memory into the field <g i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.
You do not have to read all of the objects stored under a particular name <key>. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name <key>, SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name <key>, SY-SUBRC is always 0, regardless of whether it contained the data object <f i >. If the cluster does not contain the data object <f i >, the target field remains unchanged.
Saving Data Objects in Memory
To read data objects from an ABAP program into ABAP memory, use the following statement:
Syntax
EXPORT <f1> [FROM <g 1>] <f 2> [FROM <g 2>] ... TO MEMORY ID <key>.
This statement stores the data objects specified in the list as a cluster in memory. If you do not use the option FROM <f i >, the data object <f i > is saved under its own name. If you use the FROM <g i > option, the data objet <g i > is saved under the name <f i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.
Check this link.
http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm
Thanks,
Susmitha.
Reward points for helpful answers. -
Sorting internal table with variable no of fields
Hi ,
I want to sort the internal table with variable no of fields . Every time the report is run the number of fields as well as the sequence by which the table has to be sorted changes . How to do this .
regardsHi,
Please try this.
DATA: BEGIN OF ITAB OCCURS 0,
F1(4),
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
F1(1),
F2(1),
F3(4),
END OF ITAB2.
ITAB-F1 = '01AC'.
APPEND ITAB.
ITAB-F1 = '02AB'.
APPEND ITAB.
ITAB-F1 = '01CD'.
APPEND ITAB.
ITAB-F1 = '02CA'.
APPEND ITAB.
LOOP AT ITAB.
ITAB2-F1 = ITAB-F1+2(1).
ITAB2-F2 = ITAB-F1+3(1).
ITAB2-F3 = ITAB-F1.
APPEND ITAB2.
ENDLOOP.
SORT ITAB2 BY F1 ASCENDING
F2 DESCENDING.
LOOP AT ITAB2.
WRITE: / ITAB2-F3.
ENDLOOP.
REWARD POINTS IF HELPFUL -
Amount and Quantity field during MIR7
Hello Experts,
My client wants to keep Amount and Quantity field in display mode for particular user during parking of Invoice(MIR7)
Is there any way to achieve this.
Thanks and Regards
Gyaneshgo for varients
in SHD0 transaction
here you can try to make fields display mode -
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 -
Dynamic internal table with dynamic header
Hi Members,
I have created a dynamic report ie In the selection screen i will give set of GL accounts.
Based on the GL it will separate a col like Sales GL, PF GL , Discount Gl etc. In the header portion first 3 col is constant ie it will show the vendor name and material and text remaining col is based on the GL entered in the screen it will cumulate the Total Amount and display accordingly.
This is working fine in ALV grid display, but i required to download the data to excel , while downloading to excel i am getting only the values without header,
ie title of the each col not getting . kindly guide me to solve this issue.
If i entered only sales GLs (100,101,102 ) then my output should be
vendor material mateial text 100 101 102
ddddd 11100 Raw salt 2000 1000 2500
Regards,
Mee.SHi Meenakshi,
As per my knowledge two ways of doing it...
1. when u get the final internal table..check for the fields with not initial...again update the header internal table dynamically..
2. if you get GL or PF or any such thing you can hardcode the header and display it on to excel..
Regards,
Vamshi -
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. -
Creating dynamic internal table with deep structure
Hi all,
I need to create an internal table with deep structure dynamically. I've already created tables with method 'create_dynamic_table' but I'm struggling with the deep structure.
I would need an internal table with the following structure:
DATA: BEGIN OF lt_t1,
s1 TYPE REF TO data,
s2 TYPE REF TO data,
END OF lt_t1.
S1 and S2 have to be tables.
It might be possible with RTTS but all the examples in the forums (that I've found so far) are related to at least one DDIC-structure. And that's my problem because both tables are created during runtime.
Thank you in advance
NicolaHi Frédéric,
I hope my english is good enough to explain it correctly:
We use a function builder for SEM-BPS which copies data from one Cube to another. This Cube is transactional, so you can't easily read a structure out of DDIC.
The export parameter of this function builder is a table with type 'any table'.
Until today we used a fixed definition e.g.:
TYPES:
BEGIN OF xtyp_chas,
/sie/sr_ocomp TYPE /b52/oisr_ocomp,
/sie/ts_03psp TYPE /b52/oits_03psp,
0activity TYPE /bi0/oiactivity,
0acty_elemt TYPE /bi0/oiacty_elemt,
0costelmnt TYPE /bi0/oicostelmnt,
0co_area TYPE /bi0/oico_area,
0creditor TYPE /bi0/oicreditor,
0currency TYPE /bi0/oicurrency,
0curtype TYPE /bi0/oicurtype,
0db_cr_ind TYPE /bi0/oidb_cr_ind,
0fiscper TYPE /bi0/oifiscper,
0fiscper3 TYPE /bi0/oifiscper3,
0fiscyear TYPE /bi0/oifiscyear,
0metype TYPE /bi0/oimetype,
0network TYPE /bi0/oinetwork,
0part_actty TYPE /bi0/oipart_actty,
0part_cctr TYPE /bi0/oipart_cctr,
0piobjsv TYPE /bi0/oipiobjsv,
0project TYPE /bi0/oiproject,
0unit TYPE /bi0/oiunit,
0vtdetail TYPE /bi0/oivtdetail,
0vtstat TYPE /bi0/oivtstat,
0vtype TYPE /bi0/oivtype,
0bus_area TYPE /bi0/oibus_area,
0cashdetail TYPE /bi0/oicashdetail,
0cashtype TYPE /bi0/oicashtype,
0comp_code TYPE /bi0/oicomp_code,
0coorder TYPE /bi0/oicoorder,
0cs_dimen TYPE /bi0/oics_dimen,
0cs_unit TYPE /bi0/oics_unit,
0int_bus TYPE /bi0/oiint_bus,
0part_abcpr TYPE /bi0/oipart_abcpr,
0part_coord TYPE /bi0/oipart_coord,
0part_wbsel TYPE /bi0/oipart_wbsel,
0piovalue TYPE /bi0/oipiovalue,
0profit_ctr TYPE /bi0/oiprofit_ctr,
0ps_obj TYPE /bi0/oips_obj,
0statussys0 TYPE /bi0/oistatussys0,
zfbwheroj TYPE /bic/oizfbwheroj,
END OF xtyp_chas,
BEGIN OF xtyp_kyfs,
0amount TYPE /bi0/oiamount,
0quantity TYPE /bi0/oiquantity,
zf03oaws TYPE /bic/oizf03oaws,
zf03oqty TYPE /bic/oizf03oqty,
zf03ozsta TYPE /bic/oizf03ozsta,
END OF xtyp_kyfs,
BEGIN OF xtyp_zf03g003,
s_chas TYPE xtyp_chas,
s_kyfs TYPE xtyp_kyfs,
END OF xtyp_zf03g003,
xtyp_zf03g003_t TYPE HASHED TABLE OF xtyp_zf03g003
WITH UNIQUE KEY s_chas.
DATA: lt_ibm_data TYPE xtyp_zf03g003_t,
ls_ibm_data TYPE xtyp_zf03g003.
So one table (s_chas) contains the characteristics of the Cube and the other (s_kyfs) contains the keyfigures. That's exactly the format we need for the export parameter. At the end of the program, we use the following coding to fill the export table (eto_chas):
loop at lt_ibm_data into ls_ibm_data.
collect ls_ibm_data-s_chas into eto_chas.
endloop.
So in this moment I give this table the structure that is needed to move the data into the cube. I can't change the requirement because it is a standard interface.
I would like to change that coding to be dynamically. Because if somebody changes a charasteristic or a keyfigure in the cube, we would have to change the function builder too. I don't think that the SEM-BPS department will let us know every time they've changed something anyway.
So I hope that my explanation wasn't too confusing
Nicola -
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 create Dynamic internal table with columns also created dynamically.
Hi All,
Any info on how to create a dynamic internal table along with columns(fields) also to be created dynamically.
My requirement is ..On the selection screen I enter the number of fields to be in the internal table which gets created dynamically.
I had gone thru some posts on dynamic table creation,but could'nt find any on the dynamic field creation.
Any suggestions pls?
Thanks
NaraI don't understand ...
something like that ?
* Form P_MODIFY_HEADER. *
form p_modify_header.
data : is_fieldcatalog type lvc_s_fcat ,
v_count(2) type n ,
v_date type d ,
v_buff(30).
* Update the fieldcatalog.
loop at it_fieldcatalog into is_fieldcatalog.
check is_fieldcatalog-fieldname+0(3) eq 'ABS' or
is_fieldcatalog-fieldname+0(3) eq 'VAL' .
move : is_fieldcatalog-fieldname+3(2) to v_count ,
p_perb2+5(2) to v_date+4(2) ,
p_perb2+0(4) to v_date+0(4) ,
'01' to v_date+6(2) .
v_count = v_count - 1.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = v_count
olddate = v_date
importing
newdate = v_date.
if is_fieldcatalog-fieldname+0(3) eq 'ABS'.
concatenate 'Quantité 0'
v_date+4(2)
v_date+0(4)
into v_buff.
else.
concatenate 'Montant 0'
v_date+4(2)
v_date+0(4)
into v_buff.
endif.
move : v_buff to is_fieldcatalog-scrtext_s ,
v_buff to is_fieldcatalog-scrtext_m ,
v_buff to is_fieldcatalog-scrtext_l ,
v_buff to is_fieldcatalog-reptext .
modify it_fieldcatalog from is_fieldcatalog.
endloop.
* Modify the fieldcatalog.
call method obj_grid->set_frontend_fieldcatalog
exporting it_fieldcatalog = it_fieldcatalog.
* Refresh the display of the grid.
call method obj_grid->refresh_table_display.
endform. " P_MODIFY_HEADER
Maybe you are looking for
-
Bridge to Photoshop Image Processor won't run
I'm using Photoshop CS3 Extended - V 10.0.1 and Bridge V 2.1.1.9 I'm trying to run some photos through Image Processor via Bridge. After selecting all of the photos, selecting Tools > Photoshop > Image Processor, Photoshop opens, but the Image Proces
-
Default language in identity management - please help
Hello all, Is there a way to set a default language for every user (even users from LDAP) that login to portal ? I know how to change the language in the 'General information' tab for a user - but i want to set a default language for all users includ
-
Transferring existing programs (The part I always hate!)
What programs transfer automatically and which ones do I have to re-install when installing mountain lion? Are there any extensive lists available of software re-installation problems? Also, is there any information to help re-install Parallels (Win
-
Photoshop CS6 [ Command + Click ] Layer Selection "Problem" Solved
Good afternoon fellas, I've recently noticed something uncommon when working with Photoshop CS6 under Mac OS X 10.8.x. When I naturally tried to select a Layer by the [ Command + Click ] (let's say) shortcut, it failed. This little thing was driving
-
Hotmail not syncing between MacBook and iPhone/iPad
I'm 3 days into my new MacBook Pro, which replaced a PC laptop running Outlook. With my old system, I coud check my Hotmail account in Outlook, and the messages would no longer be marked as new on my iPhone/iPad, and vice versa. With the MacBook, m