Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Assign component

amine_lamkaissi
Active Contributor
0 Kudos

Hi guys,

I have an issue with my code if i can get any help here

*Function Module call
CALL FUNCTION 'RRW3_GET_QUERY_VIEW_DATA'
EXPORTING
i_infoprovider         
= c_multi_id
i_query                
= c_req_id
i_t_parameter          
= tn_parameter
IMPORTING
e_cell_data            
= i_cell_data
e_axis_data            
= i_axis_data
EXCEPTIONS
no_applicable_data     
= 1
invalid_variable_values
= 2
no_authority           
= 3
abort                  
= 4
invalid_input          
= 5
invalid_view           
= 6
OTHERS                  = 7.

CASE sy-subrc .

WHEN 0 .
** find no. of key figures
CLEAR: lcount ,wa_axis , wa_axis_info .
READ TABLE i_axis_data  INTO wa_axis WITH KEY axis = '000'  .
IF sy-subrc EQ 0 .
CLEAR no_of_keyf .
LOOP AT wa_axis-set INTO wa_set .
AT NEW tuple_ordinal .

no_of_keyf
= no_of_keyf + 1 .
ENDAT .
ENDLOOP .
CLEAR wa_set .
ENDIF .

** find number of characteristics
READ TABLE i_axis_info  INTO wa_axis_info WITH KEY axis = '001'  .
IF sy-subrc EQ 0 .
CLEAR no_of_chars .
DESCRIBE TABLE wa_axis_info-chars LINES no_of_chars .
ENDIF .

CLEAR : iobj_detail , iobj_details .
REFRESH iobj_details .
CLEAR wa_axis_info .
* get chars. details
READ TABLE i_axis_info  INTO wa_axis_info WITH KEY axis = '001'  .
IF sy-subrc EQ 0 .
CLEAR wa_chars .
REFRESH tmp_char .

LOOP AT wa_axis_info-chars INTO wa_chars .
CLEAR wa_tmp_char .
MOVE-CORRESPONDING wa_chars TO wa_tmp_char .
INSERT wa_tmp_char INTO TABLE tmp_char.
IF NOT wa_chars-attrinm[] IS INITIAL .
LOOP AT wa_chars-attrinm INTO wa_attrinm .
CLEAR :wa_tmp_char-chanm , wa_tmp_char-caption .
MOVE: wa_attrinm-attrinm TO wa_tmp_char-chanm ,
wa_attrinm
-caption TO wa_tmp_char-caption .
INSERT wa_tmp_char INTO TABLE tmp_char.
ENDLOOP .
ENDIF .
ENDLOOP .


LOOP AT tmp_char INTO wa_chars .
CLEAR off .
CLEAR :off, moff, mlen .
FIND '___' IN SECTION OFFSET off OF
wa_chars
-chanm .
IF sy-subrc EQ 0 .
CLEAR : i_iset_iobjnm , e_iobjnm .
MOVE: wa_chars-chanm TO i_iset_iobjnm .
CALL FUNCTION 'RSD_IOBJNM_GET_FROM_INFOSET'
EXPORTING
i_iset_iobjnm
= i_iset_iobjnm
IMPORTING
e_iobjnm     
= e_iobjnm
EXCEPTIONS
name_error   
= 1
no_field     
= 2
OTHERS        = 3.

CLEAR wa_chars-chanm  .
MOVE: e_iobjnm TO wa_chars-chanm .

ELSE.

FIND '__' IN SECTION OFFSET off OF
wa_chars
-chanm
MATCH OFFSET moff
MATCH LENGTH mlen
.
IF sy-subrc EQ 0 .
off
= moff + mlen .
SHIFT wa_chars-chanm LEFT BY off PLACES .
ENDIF .
ENDIF . " two __ or three _
CLEAR: iobj_return .
REFRESH : iobj_return .

CALL FUNCTION 'Z_BAPI_IOBJ_GETDETAIL'
EXPORTING
version   
= rs_c_objvers-active
infoobject
= wa_chars-chanm
IMPORTING
details   
= iobj_detail.


IF  NOT iobj_detail IS INITIAL .
APPEND iobj_detail TO iobj_details .
CLEAR iobj_detail .
ELSE .

MOVE: wa_chars-chanm TO iobj_detail-infoobject ,
wa_chars
-caption TO iobj_detail-textlong .

APPEND iobj_detail TO iobj_details .
CLEAR iobj_detail .

ENDIF .
CLEAR : iobj_detail .
ENDLOOP .
ENDIF .

* build field cat. for building the itab
CLEAR: is_fieldcat, iobj_detail, it_fieldcat .
REFRESH : it_fieldcat .
LOOP AT iobj_details INTO iobj_detail .
is_fieldcat
-fieldname = iobj_detail-infoobject .
IF is_fieldcat-fieldname+0(1) EQ '0' .
SHIFT is_fieldcat-fieldname LEFT BY 1 PLACES .
ENDIF .
*        IF iobj_details-datatp = 'CHAR' .
*          is_fieldcat-datatype = iobj_details-datatp.
is_fieldcat
-outputlen = '130' .
*        ELSE .
is_fieldcat
-datatype = 'CHAR' . "iobj_details-datatp.
*          is_fieldcat-outputlen = iobj_details-outputlen .
*        ENDIF .

is_fieldcat
-scrtext_l = iobj_detail-textlong.
APPEND is_fieldcat TO it_fieldcat.
CLEAR : is_fieldcat , iobj_detail .
ENDLOOP .


CLEAR :n_counter, wa_axis .
READ TABLE i_axis_data  INTO wa_axis WITH KEY axis = '000'  .
IF sy-subrc EQ 0 .
LOOP AT wa_axis-set INTO wa_set .
AT NEW tuple_ordinal .

n_counter
= n_counter + 1 .

CONCATENATE 'VALUE' n_counter INTO is_fieldcat-fieldname .
is_fieldcat
-outputlen = '30'.
is_fieldcat
-datatype = 'CHAR'.
ENDAT .
CONCATENATE is_fieldcat-scrtext_l wa_set-caption INTO is_fieldcat-scrtext_l SEPARATED BY  ` ` .

*        is_fieldcat-scrtext_l = wa_set-caption.
AT END OF tuple_ordinal .
SHIFT is_fieldcat-scrtext_l LEFT DELETING LEADING ' ' .
APPEND is_fieldcat TO it_fieldcat.
CLEAR : is_fieldcat .
ENDAT .

ENDLOOP .
ENDIF .

CLEAR: meta_data, wa_meta_data .
REFRESH meta_data .
LOOP AT it_fieldcat INTO is_fieldcat .

MOVE-CORRESPONDING is_fieldcat TO wa_meta_data .
APPEND wa_meta_data TO meta_data .
CLEAR: wa_meta_data, is_fieldcat .
ENDLOOP .

* create itab
SORT it_fieldcat BY fieldname.
DELETE ADJACENT DUPLICATES FROM it_fieldcat COMPARING fieldname .
CLEAR: comp , comp_tab ,is_fieldcat .
REFRESH comp_tab .

LOOP AT it_fieldcat INTO is_fieldcat .
CLEAR op_len .
op_len
= is_fieldcat-outputlen .
comp
-name = is_fieldcat-fieldname.
comp
-type = cl_abap_elemdescr=>get_c( op_len ).
APPEND comp TO comp_tab.
CLEAR : is_fieldcat , comp .
ENDLOOP .

CLEAR struct_type .

CALL METHOD cl_abap_structdescr=>create
EXPORTING
p_components
= comp_tab
p_strict    
= cl_abap_structdescr=>false
RECEIVING
p_result    
= struct_type.

CLEAR tab_type .
CALL METHOD cl_abap_tabledescr=>create
EXPORTING
p_line_type 
= struct_type
p_table_kind
= cl_abap_tabledescr=>tablekind_std
RECEIVING
p_result    
= tab_type.

CREATE DATA dref1 TYPE HANDLE tab_type.

ASSIGN dref1->* TO <ltable>.

CREATE DATA dref TYPE HANDLE struct_type.

ASSIGN dref->* TO <l_line>.

CLEAR :wa_axis , char_count , lcount, xcount.
REFRESH tmp_set .
LOOP AT i_axis_data INTO wa_axis WHERE axis = '001' .
LOOP AT wa_axis-set INTO wa_set .
CLEAR wa_tmp_set .
MOVE-CORRESPONDING wa_set TO wa_tmp_set .
INSERT wa_tmp_set INTO TABLE tmp_set.
IF NOT wa_set-attributes[] IS INITIAL .
LOOP AT wa_set-attributes INTO wa_dattrinm .
CLEAR: wa_tmp_set-chanm , wa_tmp_set-chavl , wa_tmp_set-chavl_ext , wa_tmp_set-caption .
MOVE: wa_dattrinm-attrinm TO wa_tmp_set-chanm ,
wa_dattrinm
-attrivl TO wa_tmp_set-chavl ,
wa_dattrinm
-attrivl TO wa_tmp_set-chavl_ext ,
wa_dattrinm
-caption TO wa_tmp_set-caption .

INSERT wa_tmp_set INTO TABLE tmp_set.
ENDLOOP .
ENDIF .
ENDLOOP .
ENDLOOP .

LOOP AT tmp_set INTO wa_set .
AT NEW tuple_ordinal .
IF lcount GT 0 .
lcount
= lcount - 1 .
ENDIF .
CLEAR <l_line> .
ENDAT .
CLEAR off .

CLEAR :off, moff, mlen .
FIND '___' IN SECTION OFFSET off OF
wa_set
-chanm .
IF sy-subrc EQ 0 .
CLEAR : i_iset_iobjnm , e_iobjnm .
MOVE: wa_set-chanm TO i_iset_iobjnm .
CALL FUNCTION 'RSD_IOBJNM_GET_FROM_INFOSET'
EXPORTING
i_iset_iobjnm
= i_iset_iobjnm
IMPORTING
e_iobjnm     
= e_iobjnm
EXCEPTIONS
name_error   
= 1
no_field     
= 2
OTHERS        = 3.

CLEAR wa_set-chanm  .
MOVE: e_iobjnm TO wa_set-chanm .
ELSE.

FIND '__' IN SECTION OFFSET off OF
wa_set
-chanm
MATCH OFFSET moff
MATCH LENGTH mlen
.
IF sy-subrc EQ 0 .
off
= moff + mlen .
SHIFT wa_set-chanm LEFT BY off PLACES .
ENDIF .
ENDIF . " check three _ or two _

IF wa_set-chanm+0(1) EQ '0' .
SHIFT wa_set-chanm LEFT BY 1 PLACES .
ENDIF .
ASSIGN COMPONENT wa_set-chanm OF STRUCTURE <l_line> TO <l_field>
.
IF wa_set-chavl = '#' .
*         <l_field> =  wa_set-chavl_ext .
ELSE .
CONCATENATE wa_set-chavl_ext wa_set-caption INTO <l_field> SEPARATED BY ' ' .
ENDIF .

AT END OF tuple_ordinal .
CLEAR: xcount , char_count , n_counter .

lcount
= lcount + 1 .

LOOP AT i_cell_data INTO wa_cell FROM lcount .

n_counter
= n_counter + 1 .
IF n_counter GT no_of_keyf .
EXIT .
ENDIF .

CONCATENATE 'VALUE' n_counter INTO wf_fldnm .
ASSIGN COMPONENT wf_fldnm OF STRUCTURE <l_line> TO <l_field>.

<l_field>
= wa_cell-value .


ENDLOOP .

lcount
= lcount + no_of_keyf .
INSERT <l_line> INTO TABLE <ltable>.

ENDAT .
endloop.
endcase.

When i want to test my program, i have a short dump at the line in bold, getwa not assigned.

ASSIGN COMPONENT wa_set-chanm OF STRUCTURE <l_line> TO <l_field>.

How can i correct it?

Thanks.

Amine

4 REPLIES 4

amine_lamkaissi
Active Contributor
0 Kudos

Find atached my entire code.

Amine

Former Member
0 Kudos

Have you already debugged and checked what's included in WA_SET-CHANM? Exists the contained field name in <L_LINE>?

0 Kudos

Hi Armin,

In fact, thanks for your answer.

I have 6 components but VALUE001, VALUE002 ....VALUE006.

Amine

Sandra_Rossi
Active Contributor
0 Kudos

If you have such a dump at that line, the only possibility is that <L_LINE> was not assigned to a memory block before this statement.

As far as I can see, there is only one possibility where <L_LINE> is assigned is at the statement ASSIGN dref->* TO As this is included in IFs and LOOPs, it may not occur, so you must absolutely decide if that's normal of what you want to do in that case.

You may test whether <L_LINE> was assigned, by using IF <L_LINE> IS ASSIGNED.