‎2008 Nov 04 8:47 AM
Hi,
I have written a code in normal loop expression where it will place the value of total at first vbeln.
like this:
AT END OF vbeln.
w_output-tot_disc = w_total_disc.
MODIFY i_output FROM w_output TRANSPORTING tot_disc
WHERE vbeln = w_temp-vbeln.
CLEAR w_total_disc.
ENDAT. " AT END OF....and i have written the same code using field symbol for dynamic creation.
where i_output = <l_table>
w_output = <l_line>
like this:
AT END OF vbeln.
assign component 'TOT_DISC' of structure <l_line> TO
<l_field>.
<l_field> = w_total_disc.
MODIFY <l_table> FROM <l_line> transporting <l_field> where vbeln = w_temp-vbeln.
CLEAR w_total_disc.
ENDAT. " AT END OF....but it gives an error
Error: The specified type has no structure and therefore no component called
"<L_FIELD>" . . . .please help.
Thanks..
‎2008 Nov 04 8:53 AM
Hello,
How you have declared (<l_line>) , does it have TOT_DISC ?
Rgds,
Sandeep
‎2008 Nov 04 8:56 AM
*Dynamic Creation of columns............
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat
IMPORTING
ep_table = new_table.
*where i_fieldcat table contains 'TOT_DISC' value.
Creates a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
‎2008 Nov 04 8:59 AM
Hi,
Insert this following code....
AT END OF vbeln.
assign component 'TOT_DISC' of structure <l_line> TO
<l_field>.
if <l_field> is assigned. "-----> use this..
<l_field> = w_total_disc.
MODIFY <l_table> FROM <l_line> transporting <l_field> where vbeln = w_temp-vbeln.
CLEAR w_total_disc.
endif. "-----
ENDAT.
And check whether <l_line> contains a field name 'TOT_DISC' in debugger...
‎2008 Nov 04 9:27 AM
Yes. <l_line> contains the 'TOT_DISC' at run time.
that's the reason it is throwing an error while compling.
how to define dynamic work area ?? any idea ?
‎2008 Nov 04 10:15 AM
Hi,
Check this code.... this also creates a dynamic internal table and workarea....
DATA: struct_type TYPE REF TO cl_abap_structdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
dref TYPE REF TO data,
itab_type TYPE REF TO cl_abap_tabledescr,
wa_comp LIKE LINE OF comp_tab,
index TYPE char10.
FIELD-SYMBOLS : <tab> TYPE STANDARD TABLE,
<wa> TYPE ANY,
<temp>. "<-----------check how declared
PARAMETER col TYPE i.
DO col TIMES.
index = sy-index.
CONCATENATE 'COL' index INTO wa_comp-name.
CONDENSE wa_comp-name NO-GAPS.
wa_comp-type ?= cl_abap_datadescr=>describe_by_name( 'I' ).
APPEND wa_comp TO comp_tab.
ENDDO.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref->* TO <tab>.
CREATE DATA dref TYPE HANDLE struct_type.
ASSIGN dref->* TO <wa>.
ASSIGN COMPONENT 'COL2' OF STRUCTURE <wa> TO <temp>. "This works perfectly....
BREAK-POINT.
‎2008 Nov 04 10:06 AM
define the work area as follows:
data: if_buffer type ref to data.
field-symbols: <if_buffer> type standard table,
<wa_buffer> type any,
<f_tot_disc> type tot_disc.
try.
create data if_buffer type standard table of TABLENAME.
catch cx_root.
...
endtry.
assign if_buffer->* to <if_buffer>.
....
loop at <if_buffer> assigning <wa_buffer>.
assign component 'TOT_DISC' of structure <wa_buffer> to <f_tot_disc>.
endloop.
‎2008 Nov 04 10:21 AM
Hi,
No need to do all this :
What you are doing is incorrect :
MODIFY <l_table> FROM <l_line> transporting <l_field> where vbeln = w_temp-vbeln.
Try this :
With field symbols, you can directly access the table components of an entry in the internal table.
Now assuming that <l_table> is pointing to the current line of the table i_output. You can just write the code
<l_table>-TOL_disc = w_total_disc. This will update the field tot_disc of the line to which the field-symbol <l_table> is assigned to.
regards,
Advait
‎2010 Jul 05 3:03 PM