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

Quick Fix : "Function " and "End Function" iin ABAP Code

Former Member
0 Likes
1,026

Hello Friends. Thanks to SDN for all help on this . I am almost done this is the last error on this code. I have created 3 virtual characteristics and want to write the code in EXIT_SAPMRSRU_001 Program ZXRSRU02. to populate the 3 Virtual characteristics in cube

My Code is throwing the error about the function statement

*Function Module EXIT_SAPMRSRU_001 *

*Nesting not correct: The "ENDFUNCTION" statement has no open control *

*structure starting with "FUNCTION". open control structure starting with "FUNCTION". "FUNCTION". *

My Problem is that If I remove "END Function" it throws error on FORM that it need an end function before this. so After doing that get error Function missing at start?????

Abap Code below

data: g_t_var_range type rrs0_s_var_range.

data: begin of g_vir,

Z_MUP_ID type /BIC/SZ_MUP_ID,

ZMAT_ID type /BIC/OIZMAT_ID,

DOWNER_ID type /BIC/OIDOWNER_ID,

comp_code type /BI0/oicomp_code,

GL_ACCOUNT type /BI0/OIGL_ACCOUNT,

PROFIT_CTR type /BI0/OIPROFIT_CTR,

pr_subrc1 like sy-subrc,

pr_subrc2 like sy-subrc,

end of g_vir.

data: g_w_comp_code type /BI0/OIcomp_code.

data: g_w_GL_ACCOUNT type /BI0/OIGL_ACCOUNT.

data: g_w_PROFIT_CTR type /BI0/OIPROFIT_CTR.

types: g_s_MORN type sorted table of /BIC/AZDAFISR000 with unique key COMP_CODE GL_ACCOUNT PROFIT_CTR.

data: g_t_MORN1 type g_s_MORN with header line,

g_t_MORN2 type g_s_MORN with header line.

data: g_t_chanm type rrke_s_chanm,

g_t_kyfnm type rsdkyf.

data: g_pos_ZBDGLT_0_0COMP_CODE type i,

g_pos_ZBDGLT_0_0GL_ACCOUNT type c,

g_pos_ZBDGLT_0_0PROFIT_CTR type c,

g_pos_ZBDGLT_0_Z_MUP_ID type c,

g_pos_ZBDGLT_0_ZMAT_ID type c,

g_pos_ZBDGLT_0_DOWNER_ID type c.

case i_s_rkb1d-infocube.

when 'ZBDGLT_0'.

  • Characteristics and Units

g_t_chanm-mode = rrke_c_mode-read.

g_t_chanm-chanm = '0comp_code'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = '0GL_ACCOUNT'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = '0PROFIT_CTR'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'Z_MUP_ID'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'ZMAT_ID'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'DOWNER_ID'. append g_t_chanm to e_t_chanm.

endcase.

select *

from /BIC/AZDAFISR000

into table g_t_MORN1.

endfunction.

FORM USER_ZBDGLT_0 USING i_s_rkb1d TYPE rsr_s_rkb1d

CHANGING c_s_data TYPE any.

  • Define Field Symbols

field-symbols: <0comp_code>, <0GL_ACCOUNT>, <0PROFIT_CTR>,

<Z_MUP_ID>, <ZMAT_ID>, <DOWNER_ID>.

data: g_t_var_range type rrs0_s_var_range.

data: begin of g_vir,

Z_MUP_ID type /BIC/SZ_MUP_ID,

ZMAT_ID type /BIC/OIZMAT_ID,

DOWNER_ID type /BIC/OIDOWNER_ID,

comp_code type /BI0/oicomp_code,

GL_ACCOUNT type /BI0/OIGL_ACCOUNT,

PROFIT_CTR type /BI0/OIPROFIT_CTR,

pr_subrc1 like sy-subrc,

pr_subrc2 like sy-subrc,

end of g_vir.

data: g_w_comp_code type /BI0/OIcomp_code.

data: g_w_GL_ACCOUNT type /BI0/OIGL_ACCOUNT.

data: g_w_PROFIT_CTR type /BI0/OIPROFIT_CTR.

types: g_s_MORN type sorted table of /BIC/AZDAFISR000 with unique key COMP_CODE GL_ACCOUNT PROFIT_CTR.

data: g_t_MORN1 type g_s_MORN with header line,

g_t_MORN2 type g_s_MORN with header line.

data: g_t_chanm type rrke_s_chanm,

g_t_kyfnm type rsdkyf.

data: g_pos_ZBDGLT_0_0COMP_CODE type i,

g_pos_ZBDGLT_0_0GL_ACCOUNT type c,

g_pos_ZBDGLT_0_0PROFIT_CTR type c,

g_pos_ZBDGLT_0_Z_MUP_ID type c,

g_pos_ZBDGLT_0_ZMAT_ID type c,

g_pos_ZBDGLT_0_DOWNER_ID type c.

  • Get Material, Plant and Quantity

assign: component g_pos_ZBDGLT_0_0COMP_CODE

of structure c_s_data to <0COMP_CODE>,

component g_pos_ZBDGLT_0_0GL_ACCOUNT

of structure c_s_data to <0GL_ACCOUNT>,

component g_pos_ZBDGLT_0_0PROFIT_CTR

of structure c_s_data to <0PROFIT_CTR>.

  • Insert Cost Amount 1 if cost price id 1 <> Blank

  • *if not g_vir-Z_MUP_ID is initial.

assign: component g_pos_ZBDGLT_0_Z_MUP_ID

of structure c_s_data to <Z_MUP_ID>,

component g_pos_ZBDGLT_0_ZMAT_ID

of structure c_s_data to <ZMAT_ID>,

component g_pos_ZBDGLT_0_DOWNER_ID

of structure c_s_data to <DOWNER_ID>.

if g_t_MORN1-comp_code <> <0comp_code>

or g_t_MORN1-GL_ACCOUNT <> <0GL_ACCOUNT>

or g_t_MORN1-PROFIT_CTR <> <0PROFIT_CTR>.

read table g_t_MORN1

with table key comp_code = <0comp_code>

GL_ACCOUNT = <0GL_ACCOUNT>

PROFIT_CTR = <0PROFIT_CTR>.

g_vir-pr_subrc1 = sy-subrc.

if g_vir-pr_subrc1 <> 0.

read table g_t_MORN1

with table key comp_code = g_vir-comp_code

GL_ACCOUNT = g_vir-GL_ACCOUNT

PROFIT_CTR = g_vir-PROFIT_CTR.

g_vir-pr_subrc1 = sy-subrc.

endif.

endif.

if g_vir-pr_subrc1 = 0.

<Z_MUP_ID> = g_t_MORN1-/BIC/Z_MUP_ID.

<ZMAT_ID> = g_t_MORN1-/BIC/ZMAT_ID.

<DOWNER_ID> = g_t_MORN1-/BIC/DOWNER_ID.

endif.

ENDFORM. "USER_ZBDGLT_0

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
584

did you implement this code in user exit? if yes, then there should be an include program with in which you must have writter all the code. Where did you wrtie/create the FORM from? The structure should be like this

**if its a user exit it should have been like this - then you double click on include program - hit enter if you get a warning. Write all your code in that include using whatever import prameters you get and then passing back export parameters.

If you want to write any perform staments inside ZXRSRU02 - then write perform <form_name> and double click on form name and follow the steps to create the perorm - activate all objects together at the end.

function

include ZXRSRU02.

endfunction.

Hello Friends. Thanks to SDN for all help on this . I am almost done this is the last error on this code. I have created 3 virtual characteristics and want to write the code in EXIT_SAPMRSRU_001 Program ZXRSRU02. to populate the 3 Virtual characteristics in cube

My Code is throwing the error about the function statement

*Function Module EXIT_SAPMRSRU_001 *

*Nesting not correct: The "ENDFUNCTION" statement has no open control *

*structure starting with "FUNCTION". open control structure starting with "FUNCTION". "FUNCTION". *

My Problem is that If I remove "END Function" it throws error on FORM that it need an end function before this. so After doing that get error Function missing at start?????

Abap Code below

data: g_t_var_range type rrs0_s_var_range.

data: begin of g_vir,

Z_MUP_ID type /BIC/SZ_MUP_ID,

ZMAT_ID type /BIC/OIZMAT_ID,

DOWNER_ID type /BIC/OIDOWNER_ID,

comp_code type /BI0/oicomp_code,

GL_ACCOUNT type /BI0/OIGL_ACCOUNT,

PROFIT_CTR type /BI0/OIPROFIT_CTR,

pr_subrc1 like sy-subrc,

pr_subrc2 like sy-subrc,

end of g_vir.

data: g_w_comp_code type /BI0/OIcomp_code.

data: g_w_GL_ACCOUNT type /BI0/OIGL_ACCOUNT.

data: g_w_PROFIT_CTR type /BI0/OIPROFIT_CTR.

types: g_s_MORN type sorted table of /BIC/AZDAFISR000 with unique key COMP_CODE GL_ACCOUNT PROFIT_CTR.

data: g_t_MORN1 type g_s_MORN with header line,

g_t_MORN2 type g_s_MORN with header line.

data: g_t_chanm type rrke_s_chanm,

g_t_kyfnm type rsdkyf.

data: g_pos_ZBDGLT_0_0COMP_CODE type i,

g_pos_ZBDGLT_0_0GL_ACCOUNT type c,

g_pos_ZBDGLT_0_0PROFIT_CTR type c,

g_pos_ZBDGLT_0_Z_MUP_ID type c,

g_pos_ZBDGLT_0_ZMAT_ID type c,

g_pos_ZBDGLT_0_DOWNER_ID type c.

case i_s_rkb1d-infocube.

when 'ZBDGLT_0'.

  • Characteristics and Units

g_t_chanm-mode = rrke_c_mode-read.

g_t_chanm-chanm = '0comp_code'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = '0GL_ACCOUNT'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = '0PROFIT_CTR'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'Z_MUP_ID'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'ZMAT_ID'. append g_t_chanm to e_t_chanm.

g_t_chanm-chanm = 'DOWNER_ID'. append g_t_chanm to e_t_chanm.

endcase.

select *

from /BIC/AZDAFISR000

into table g_t_MORN1.

endfunction.

FORM USER_ZBDGLT_0 USING i_s_rkb1d TYPE rsr_s_rkb1d

CHANGING c_s_data TYPE any.

  • Define Field Symbols

field-symbols: <0comp_code>, <0GL_ACCOUNT>, <0PROFIT_CTR>,

<Z_MUP_ID>, <ZMAT_ID>, <DOWNER_ID>.

data: g_t_var_range type rrs0_s_var_range.

data: begin of g_vir,

Z_MUP_ID type /BIC/SZ_MUP_ID,

ZMAT_ID type /BIC/OIZMAT_ID,

DOWNER_ID type /BIC/OIDOWNER_ID,

comp_code type /BI0/oicomp_code,

GL_ACCOUNT type /BI0/OIGL_ACCOUNT,

PROFIT_CTR type /BI0/OIPROFIT_CTR,

pr_subrc1 like sy-subrc,

pr_subrc2 like sy-subrc,

end of g_vir.

data: g_w_comp_code type /BI0/OIcomp_code.

data: g_w_GL_ACCOUNT type /BI0/OIGL_ACCOUNT.

data: g_w_PROFIT_CTR type /BI0/OIPROFIT_CTR.

types: g_s_MORN type sorted table of /BIC/AZDAFISR000 with unique key COMP_CODE GL_ACCOUNT PROFIT_CTR.

data: g_t_MORN1 type g_s_MORN with header line,

g_t_MORN2 type g_s_MORN with header line.

data: g_t_chanm type rrke_s_chanm,

g_t_kyfnm type rsdkyf.

data: g_pos_ZBDGLT_0_0COMP_CODE type i,

g_pos_ZBDGLT_0_0GL_ACCOUNT type c,

g_pos_ZBDGLT_0_0PROFIT_CTR type c,

g_pos_ZBDGLT_0_Z_MUP_ID type c,

g_pos_ZBDGLT_0_ZMAT_ID type c,

g_pos_ZBDGLT_0_DOWNER_ID type c.

  • Get Material, Plant and Quantity

assign: component g_pos_ZBDGLT_0_0COMP_CODE

of structure c_s_data to <0COMP_CODE>,

component g_pos_ZBDGLT_0_0GL_ACCOUNT

of structure c_s_data to <0GL_ACCOUNT>,

component g_pos_ZBDGLT_0_0PROFIT_CTR

of structure c_s_data to <0PROFIT_CTR>.

  • Insert Cost Amount 1 if cost price id 1 <> Blank

  • *if not g_vir-Z_MUP_ID is initial.

assign: component g_pos_ZBDGLT_0_Z_MUP_ID

of structure c_s_data to <Z_MUP_ID>,

component g_pos_ZBDGLT_0_ZMAT_ID

of structure c_s_data to <ZMAT_ID>,

component g_pos_ZBDGLT_0_DOWNER_ID

of structure c_s_data to <DOWNER_ID>.

if g_t_MORN1-comp_code <> <0comp_code>

or g_t_MORN1-GL_ACCOUNT <> <0GL_ACCOUNT>

or g_t_MORN1-PROFIT_CTR <> <0PROFIT_CTR>.

read table g_t_MORN1

with table key comp_code = <0comp_code>

GL_ACCOUNT = <0GL_ACCOUNT>

PROFIT_CTR = <0PROFIT_CTR>.

g_vir-pr_subrc1 = sy-subrc.

if g_vir-pr_subrc1 <> 0.

read table g_t_MORN1

with table key comp_code = g_vir-comp_code

GL_ACCOUNT = g_vir-GL_ACCOUNT

PROFIT_CTR = g_vir-PROFIT_CTR.

g_vir-pr_subrc1 = sy-subrc.

endif.

endif.

if g_vir-pr_subrc1 = 0.

<Z_MUP_ID> = g_t_MORN1-/BIC/Z_MUP_ID.

<ZMAT_ID> = g_t_MORN1-/BIC/ZMAT_ID.

<DOWNER_ID> = g_t_MORN1-/BIC/DOWNER_ID.

endif.

ENDFORM. "USER_ZBDGLT_0

1 REPLY 1
Read only

Former Member
0 Likes
585

did you implement this code in user exit? if yes, then there should be an include program with in which you must have writter all the code. Where did you wrtie/create the FORM from? The structure should be like this

**if its a user exit it should have been like this - then you double click on include program - hit enter if you get a warning. Write all your code in that include using whatever import prameters you get and then passing back export parameters.

If you want to write any perform staments inside ZXRSRU02 - then write perform <form_name> and double click on form name and follow the steps to create the perorm - activate all objects together at the end.

function

include ZXRSRU02.

endfunction.