Application Development and Automation 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: 
Read only

how the code works?

Former Member
0 Likes
521

hi guys,

sorry to ask some silly question. but can any one explain the below code what is does? i have no idea on it.

what does - USING, DESCRIBE TABLE, are use for?

how does this part fetch the data from table into the internal table?

thanks


form validate_sernos_z41_bundle  tables it_bom_link STRUCTURE zmm_bom_link
                                 it_sernos_file STRUCTURE alsmex_tabline
                          using fs_mseg like mseg
                                w_qty
                                w_field_name
                                w_tablename.



* No of serial numbers entered for the current line item
  DESCRIBE TABLE it_bom_link LINES lw_no_of_snos.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
504

Ben,

USING : By this you can pass the values inside of the subroutine.This is just like

IMPORT the values not like EXPORT from subroutine.

DESCRIBE TABLE it_bom_link LINES lw_no_of_snos.

Describe : IT will give the no. of records present in that internal table.

Don't forget to reward if useful.......

3 REPLIES 3
Read only

Former Member
0 Likes
504

HI Ben

Describe statement doesnt fetch data, but it gives the details of the internal table.

As per the statement in your code, it retreives the number of records existing in the internal table it_bom_link

Here is an extract from the help for your understanding.


DESCRIBE - Return attributes of an internal table 


Basic form 
DESCRIBE TABLE itab. 



Effect 
Returns the attributes of the internal table itab. You must use at least one of the additions listed below: 



Note 
The DESCRIBE statement cannot be used for all ABAP types. In connection with ABAP Objects, SAP has introduced a RTTI concept based on system classes to determine type attributes at runtime. This concept applies to all ABAP types and as such covers all the functions of the DESCRIBE TABLE statement. 



Extras: 

1. ... LINES n 

2. ... OCCURS n 

3. ... KIND   k 



Addition 1 
... LINES n 


Effect 
Places the number of filled lines of the table t in the field lin. The value returned to lin has type I. 

Note 
The number of filled lines of the table itab can also be ascertained using the predefined function lines( itab ). 



Example
DATA: N    TYPE I, 

      ITAB TYPE TABLE OF I. 
... 
CLEAR ITAB. 
APPEND 36 TO ITAB. 
DESCRIBE TABLE ITAB LINES N. 



Result: N contains the value 1. 



Addition 2 
... OCCURS n 


Effect 
Passes the size of the OCCURS parameter from the table definition (as defined with DATA) to the variable n. The value returned to n has type I. 



Example
DATA: N1    TYPE I, 
      N2    TYPE I, 
      ITAB1 TYPE TABLE OF I INITIAL SIZE 10, 
      ITAB2 TYPE I OCCURS 5. 
DESCRIBE TABLE ITAB1 OCCURS N1. 
DESCRIBE TABLE ITAB2 OCCURS N2. 



Result: OCC contains the value 10 and N2 the value 5. 



*Addition 3* 
... KIND k 


*Effect* 
Writes the table type from itab to the variables n. The value returned to k is of type C. The constants SYDES_KIND-STANDARD, SYDES_KIND-SORTED and SYDES_KIND-HASHED are defined in the type group SYDES for the return values. 



Example 
Generic FORM routine any table type 


TYPE-POOLS: SYDES. 
... 
FORM GENERIC_FORM USING ITAB TYPE ANY TABLE. 
  DATA: K TYPE C. 
  DESCRIBE TABLE ITAB KIND K. 
  CASE K. 
    WHEN SYDES_KIND-STANDARD. 
      ... 
    WHEN SYDES_KIND-SORTED. 
      ... 
    WHEN SYDES_KIND-HASHED. 
      ... 
  ENDCASE. 
ENDFORM. 



*Notes* 

Performance: The runtime for executing the DESCRIBE TABLE statement is approximately 4 msn (standardized microseconds). 

The DESCRIBE TABLE statement also passes values to the SY-TFILL and SY-TLENG System fields 

Regards

Eswar

Read only

gopi_narendra
Active Contributor
0 Likes
504

DESCRIBE gives you the number of lines/records/rows in an internal table.

DESCRIBE table it_tab LINES n.

n gives the no of lines in internal table it_tab.

Regards

Gopi

Read only

Former Member
0 Likes
505

Ben,

USING : By this you can pass the values inside of the subroutine.This is just like

IMPORT the values not like EXPORT from subroutine.

DESCRIBE TABLE it_bom_link LINES lw_no_of_snos.

Describe : IT will give the no. of records present in that internal table.

Don't forget to reward if useful.......