Skip to Content
0
Former Member
Oct 07, 2005 at 04:26 PM

Forms in function module

170 Views

Hello,

I am new to ABAP and i am trying to loop through one table and make another table if certain fields match. Here is my code. It does not work 😔 Any help would be greatly appreciated.

FUNCTION Z_ORGBUILDER_CONN.

*"----


""Local interface:

*" IMPORTING

*" VALUE(OTYPE) LIKE OBJEC-OTYPE

*" VALUE(OBJID) LIKE OBJEC-OBJID

*" VALUE(PATHID) LIKE GDSTR-WEGID

*" VALUE(PLVAR) LIKE OBJEC-PLVAR

*" EXPORTING

*" VALUE(RETURN) LIKE BAPIRET2 STRUCTURE BAPIRET2

*" TABLES

*" L_ZCONN_TAB TYPE ZCONN_TAB

*" RESULT_TAB STRUCTURE SWHACTOR OPTIONAL

*" RESULT_OBJEC STRUCTURE OBJEC OPTIONAL

*" RESULT_STRUC STRUCTURE STRUC OPTIONAL

*" L_ZCONN_TAB1 TYPE ZCONN_TAB

*"----


DATA: z_struc type zconn_struc.

DATA: OBJectID type struc-objid.

DATA: pointer type struc-pup.

CALL FUNCTION 'RH_STRUC_GET'

EXPORTING

act_otype = otype

act_objid = objid

act_plvar = plvar

act_wegid = pathid

TABLES

result_tab = result_tab

result_struc = result_struc

result_objec = result_objec

EXCEPTIONS

no_plvar_found = 1

no_entry_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

RAISE no_roots_found.

ENDIF.

LOOP AT result_struc.

z_struc-objectID = result_struc-OBJID.

z_struc-pointer = result_struc-PUP.

Append z_struc to l_zconn_tab.

ENDLOOP.

LOOP AT l_zconn_tab.

objectid = l_zconn_tab-OBJectID.

pointer = l_zconn_tab-pointer.

PERFORM FIND_PARENT using objectID

pointer

changing l_zconn_tab1.

endloop.

ENDFUNCTION.

FORM FIND_PARENT using u_objectID like objectID

u_pointer like pointer

changing c_zconn_tab like l_zconn_tab1.

LOOP AT result_struc.

if result_struc-pup = u_pointer.

z_struc-objectID = u_objectID.

z_struc-parentID = result_struc-objid.

endif.

Append z_struc to l_zconn_tab.

ENDLOOP.

ENDFORM.