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

Number of Line items per Invoice - SPlit Critera ZUK

Hi,

I have a requirement to split 3 Line Items per Invoice.

for Ex : -

Order Document has 9 line items, in this case it should create 3 invoices.

To achive this functionality we have created a Form Routine

Upon few conditions we are populaing ZUK.

DATA: BEGIN OF zuk,
modul(3) VALUE '003',
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
vgbel LIKE vbrp-vgbel,
billno LIKE tvko-maxbi,
END OF zuk.

DATA: BEGIN OF j_1b_size_split OCCURS 0,
kunrg LIKE vbrk-kunrg,
kunag LIKE vbrk-kunag,
zterm LIKE vbrk-zterm.
INCLUDE STRUCTURE zuk.

DATA: itemno LIKE tvko-maxbi.
DATA: END OF j_1b_size_split.

zuk-billno = j_1b_size_split-billno.
zuk-vtweg = vbak-vtweg.
zuk-spart = vbrp-spart.
IF kurgv-perfk = space.
zuk-vgbel = vbrp-vgbel.
ENDIF.
vbrk-zukri = zuk.

It is creating two invoices and displaying only 1 Line item in it.

I am sure, we are passing something incorrectly to vbrk-zukri = zuk.

Can you explain if we need pass something to ZUK so that we can get only 3 line items per Invoice?

Any suggestions will be appreciated !

Best Regards,

NKC

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 26, 2013 at 08:18 PM

    I got totally lost trying to mentally merge two pieces of unformatted code, but in general you'd have to pass the same value X 3 times then same value Y 3 times, etc. The fact that, as you're saying, two invoices 1 line each were generated for 9 item order signals that there might be some other issue actually. If the value was just filled incorrectly, you still would've ended up with all line items invoiced (possibly in 9 invoices).

    This is a very simple algorithm though, have you tried debugging it?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Jelena,

      Yes the Test document was not there and it was a copy of another routine.

      I have change the Total Logic.


      DATA: BEGIN OF zuk,
      vtweg LIKE vbak-vtweg,
      spart LIKE vbak-spart,
      vgbel LIKE vbrp-vgbel,
      billno LIKE tvko-maxbi,
      END OF zuk.

      * To hold the value without getting initialized.
      STATICS : gw_count TYPE i ,
      gw_billcnt TYPE i VALUE 1.


      IF vbrk-vkorg = gw_vkorg AND "Sales org
      vbrk-bukrs = gw_bukrs. "Company Code

      * Maximum number of billing items active
      IF NOT gw_maxbi IS INITIAL. "

      * Check number of billing items against max. defined by gw_MAXBI IN ztuhcd1
      gw_count = gw_count + 1.
      zuk-billno = gw_billcnt.

      * Check if no of records exceeds max no of items allowed.
      IF gw_count > gw_maxbi.

      * Add billing doc. number to split criteria
      gw_billcnt = gw_billcnt + 1.
      zuk-billno = gw_billcnt.

      *Once it reaches max no of line items, it will initialize the value to 1.
      gw_count = 1.

      ENDIF.
      * End of billing document split by number of allowed items

      * Addition of logic to append line items into new invoice no

      zuk-vtweg = vbak-vtweg.
      zuk-spart = vbrp-spart.
      vbrk-zukri = zuk.

      ENDIF.
      ENDIF.

      It is working now.

      Thank you!

      NKC

  • author's profile photo Former Member
    Former Member
    Posted on Aug 26, 2013 at 02:59 PM

    Somewhere, are you appending j_1b_size_split on each itteration?

    Neal

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Neal,

      Thanks for your quick reply!

      Yes I am appending the j_1b_size_split on each iteration and it is holding each single item per one iteration.


      DATA: BEGIN OF zuk,
      modul(3) VALUE '003',
      vtweg LIKE vbak-vtweg,
      spart LIKE vbak-spart,
      vgbel LIKE vbrp-vgbel,
      billno LIKE tvko-maxbi,
      END OF zuk.

      DATA: BEGIN OF j_1b_size_split OCCURS 0,
      kunrg LIKE vbrk-kunrg,
      kunag LIKE vbrk-kunag,
      zterm LIKE vbrk-zterm.
      INCLUDE STRUCTURE zuk.

      DATA: itemno LIKE tvko-maxbi.
      DATA: END OF j_1b_size_split.


      IF NOT tvko-maxbi IS INITIAL.

      * Get billing doc. item number split data
      READ TABLE j_1b_size_split
      WITH KEY kunrg = vbrk-kunrg
      kunag = vbrk-kunag
      zterm = vbrk-zterm
      vgbel = vbrp-vgbel.
      IF sy-subrc <> 0.
      CLEAR j_1b_size_split.
      MOVE-CORRESPONDING vbrk TO j_1b_size_split.
      MOVE-CORRESPONDING vbrp TO j_1b_size_split.
      endif.


      IF j_1b_size_split-itemno < gw_maxbi.
      j_1b_size_split-itemno
      = j_1b_size_split-itemno + 1.
      ELSE.
      j_1b_size_split-billno
      = j_1b_size_split-billno + 1.
      j_1b_size_split-itemno = 1.
      ENDIF.

      READ TABLE j_1b_size_split INTO j_1b_size_copy
      WITH KEY kunrg = vbrk-kunrg
      kunag = vbrk-kunag
      zterm = vbrk-zterm
      vgbel = vbrp-vgbel.
      IF sy-subrc = 0.
      MODIFY j_1b_size_split
      TRANSPORTING itemno billno
      WHERE kunrg = vbrk-kunrg
      AND kunag = vbrk-kunag
      AND zterm = vbrk-zterm
      AND vgbel = vbrp-vgbel.
      ELSE.
      APPEND j_1b_size_split.

      Best Regards,

      NKC

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.