Skip to Content
author's profile photo Former Member
Former Member

Forms in function module

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 07, 2005 at 04:39 PM

    Mark,

    I am not very clear what are you trying to do.

    However in your code, you do have a problem.

    In the loop of the internal table l_zconn_tab, you are calling form FIND_PARENT .

    There are problems here.

    1. You are passing a table l_zconn_tab1, which I can't find anywhere.

    2. Inside the FORM you are appending rows to the same table l_zconn_tab, which is the same as the table which you are looping at. That means that you are appending rows to the same table which you looping at. That means if the rows are getting appended this loop will be infinite.

    3. The actual parameter to the form c_zcomm_tab is not being utilized at all. Probably inside the form you might want to append rows to this table.

    I am not sure if this solves your problem as I am not getting what you are trying to do.

    Let me know if this helps,

    Regards,

    Ravi

    NOte : Please reward points if this helps.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.