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: 

VOFM Requirement coding

tony_bramhill2
Participant
0 Kudos

Advice sought..

I want to use an Output Control <i>requirement</i> to determine if an event should be triggered by Sales Order Output Control. The value I want to use to decide is the CEPOK flag on the sales order item line. Any line with CEPOK set to 'B' should satisfy the <i>requirement</i>. However I presume the KOMBPV1 structure will only hold a single line.. Which line? and how do I examine all lines? And how come KOMBPV1 doesn't have the VBELN key field? I was going to use some code like:

SELECT SINGLE CEPOK

FROM VBAP INTO VBAP-CEPOK

WHERE VBELN = KOMPBV1-VBELN

AND CEPOK = 'B' OR CEPOK = 'C'.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

1) Is your output type at the line item level??

2) Also you can extend the communication structure KOMPBV1 with the field CEPOK using APPEND structures..

Then check the field KOMPBV1-CEPOK = 'C' OR 'B'..To propose the output type..

SAP will automatically move the value to the communication structure KOMPBV1..

Thanks,

Naren

7 REPLIES 7

Former Member
0 Kudos

Hi,

1) Is your output type at the line item level??

2) Also you can extend the communication structure KOMPBV1 with the field CEPOK using APPEND structures..

Then check the field KOMPBV1-CEPOK = 'C' OR 'B'..To propose the output type..

SAP will automatically move the value to the communication structure KOMPBV1..

Thanks,

Naren

Former Member
0 Kudos

Hi,

Find answer to your question below.

[1]. In VOFM. the routine related to your requirement is in under menu "Requirements --> Output control".

[2]. The routine you should look at here is

- <b>Routine 20</b> (Order (Hdr) incompl.) If you want to triggers the output based on whole sales document ( if all line item satisfy your requirement ) with menu "Extras --> Output --> Header --> Edit"

- <b>Routine 21</b> (Order (Itm) incompl.) . If you want to trigger the output based on indivisual lines with menu "Extras --> Output --> Item --> Edit" with one item selected.

[3]. Copy this routine in customer namespace ( 600 - 999 ). You will need an access key for this. Let's say you are implemening the routine number 621, then you will need access key for object <b>R3TR PROG RV61B621</b>. Choose the application V1 here.

[4]. Regarding your question, VBELN is not available, <b>you need to get it from call stack</b>. You have access to following stack variables here.

-- (SAPMV45A)VBAK : Structure VBAK

-- (SAPMV45A)VBAP : Structure VBAP ( in routine 20 POSNR = 0000 )

-- (SAPMV45A)XVBAK : Strucutre XVBAK

-- (SAPMV45A)XVBAP : Table XVBAP ( it contains all lines )

[5]. The routine ( 20 or 21 ) triggers only once. It tirggers when you select your output using "Extras --> Output --> Header / Item --> Edit" and Hit SAVE. On hitting Saving the sales document, the routine triggers once, it checks your requirement and detemine output trigger based on it.

I hope i clarify your doubt.

Let me know if you have any question.

Regards,

RS

0 Kudos

Thanks RS, that is a great help.

However there are a couple of things I don't follow:

1. I created a new requirement (940) following your suggestion by copying existing requirement 21. This requirement is configured on my new Output Type (ZPRC). <i>I don't have 20 or 21 specified anywhere</i>. I take it that 20 (or 21) is automatically executed when proposing output types because they are standard SAP? Whereas my 940 is executed <i>only because I have configured it</i>?

2. I find that the requirement (940) is executed when I press SAVE on a new Sales Order (i have a breakpoint in the code), yet the KOMKBV1-VBELN field is blank. But <i>after</i> saving, if I follow the EXTRAS->OUTPUT->HEADER menu option, the KOMKBV1-VBELN field is populated. I need to check the status of the order on SAVE. Any ideas?

thanks in advance

0 Kudos

Hi,

I did not get your first point clearly. Can you please clarify again.

How routine normally trigges is, if you want to use routine '940' for output then it should be configured with your output type ZPRC. It is configured in "output determine procedure". Ask your functional owner to configure the output type accordingly.

Regarding your second point, yes KOMKBV1-VBELN field is populated when you select "EXTRAS --> OUTPUT --> HEADER". As i told you, you get other values from call stack. These data is:

-- (SAPMV45A)VBAK : Structure VBAK

-- (SAPMV45A)VBAP : Structure VBAP ( in routine 20 POSNR = 0000 )

-- (SAPMV45A)XVBAK : Strucutre XVBAK

-- (SAPMV45A)XVBAP : Table XVBAP ( it contains all lines )

You can use XVBAP dtata to check 'CEPOK' field for all line item

Let me know if you have any question.

Regards,

RS

Let me know if yo

0 Kudos

Thanks RS.

No problem with the first point - I have requirement 940 configured for my new Output Type.

However..

The problem I have is, I want my event (output type ZPRC) to be triggered <i>at the moment the Sales Document is <b>saved</b></i>. I can't wait for a user to use EXTRAS->OUTPUT->HEADER/LINE at a later time, because the event is required immediately as the document is saved.

For my new output type (ZPRC), the requirement i created (940) <i>is executed at the time of <b>save</b> of the document,</i> yet the KOMKBV1structure which is available to requirement (940) is not fully populated. I don't understand why the system would execute the requirement at <b>save document time</b> when the values the requirement might need are not made available. Yet when a user goes to EXTRAS->OUTPUT->HEADER/LINE at a later time, VBELN is available.

It seems I must add extra code to my requirement (940) to examine the CALL STACK in order to get VBELN. Then, using VBELN i can go to the database table VBAP and examine all the CEPOK values.

BTW, is SYSTEM_CALLSTACK the only way to get access to the Call Stack? We are (unfortunately) still on 4.5b and this FM doesn't seem to be available.

many thanks for your help.

0 Kudos

Hi,

Get the value from call stack with following code.

You might only need XVBAP values only. Check if your requirements meet with XVBAP only, then you can remove the code related to VBAK and VBAP.

Let me know if you have find any issue with this code.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
TYPES:   BEGIN OF xvbap.
        INCLUDE STRUCTURE vbapvb.
TYPES:   END OF xvbap.

TYPES: t_vbap TYPE STANDARD TABLE OF xvbap.

**-- Field Symbols Declarations
FIELD-SYMBOLS :<fs_vbak>  TYPE ANY,
               <fs_vbap>  TYPE ANY,
               <fs_xvbap> TYPE t_vbap.

**-- Structure Declaration for field symbols
DATA :  str_vbap  TYPE vbap,
        str_vbak  TYPE vbak.

*Table for XVBAP
DATA: lit_xvbap TYPE t_vbap.

*Work area
DATA: lst_xvbap TYPE xvbap.

DATA: l_cepok LIKE vbap-cepok.

**--- Field Symbol Declarations
DATA : l_vbak(20)  VALUE '(SAPMV45A)VBAK',
       l_vbap(20)  VALUE '(SAPMV45A)VBAP',
       l_xvbap(20) VALUE '(SAPMV45A)XVBAP'.

**---Logic to get the Sales Order Header data
ASSIGN (l_vbak) TO <fs_vbak>.
IF sy-subrc EQ 0.
  IF NOT <fs_vbak> IS INITIAL.
    MOVE <fs_vbak> TO str_vbak.
  ENDIF.
ENDIF.

**---Logic to get the Sales Order Item data
ASSIGN (l_vbap) TO <fs_vbap>.
IF sy-subrc EQ 0.
  IF NOT <fs_vbap> IS INITIAL.
    MOVE <fs_vbap> TO str_vbap.
  ENDIF.
ENDIF.

**---Logic to get the Sales Order Item data (all item)
ASSIGN (l_xvbap) TO <fs_xvbap>.
IF sy-subrc EQ 0.
  IF NOT <fs_xvbap> IS INITIAL.
    MOVE <fs_xvbap> TO lit_xvbap.
  ENDIF.
ENDIF.

IF NOT lit_xvbap[] IS INITIAL.
* loop at sales order line item
  LOOP AT lit_xvbap INTO lst_xvbap.
    l_cepok = lst_xvbap-cepok.
    CHECK: l_cepok >< 'B' AND l_cepok >< 'C'.
    sy-subrc = 0.
  ENDLOOP.
ENDIF.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Regards,

RS

tony_bramhill2
Participant
0 Kudos

Thanks RS, I am getting the values from the call stack as u suggested.

I had to make a slight change to the code:

(SAPMV45A)VBAP ==> (SAPMV45A)VBAP[]

I remain surprised that R/3 does not supply VBELN in the KOM structure when application V1 invoked Message Control and the requirement is executed.

Many thanks for your advice.