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: 

Problem with proforma invoice Script

Former Member
0 Kudos

Dear Experts,

For one Billing document one order is there, for this order 2 items is there whenever we generating proforma invoice for these items Export license number is fetched for first line item requiring the export license. For the next item, the same data gets copied even though the Export license is not required for that material.

for this requirement i did some code modification....

SE71 Main Window modified code for layout ZINVOICE01

PERFORM LICENSE IN PROGRAM ZPROGRAM *

USING &VBDKR-VBELN&

USING &VBDKR-LLAND&

USING &VBDKR-VBELN_VAUF&

USING &TVBDPR-POSNR& " CHANGES MADE ON

CHANGING &EXGEN&

ENDPERFORM

IF &VBDKR-FKART& = 'ZFV' OR &VBDKR-FKART& = 'L2' OR &VBDKR-FKART& = 'F5' >

ELSE

,,&EXGEN&

ENDIF

se38 Zprogram .

FORM LICENSE TABLES INTTAB STRUCTURE ITCSY

OUTTAB STRUCTURE ITCSY.

*

DATA : VBELN LIKE VBRK-VBELN,

DEST_CTRY LIKE VBDKR-LLAND,

ORDER LIKE VBAK-VBELN,

  • CHANGES MADE ON .

ITEM LIKE VBAP-POSNR.

  • CHANGES MADE ON .

*

  • REFRESH INTTAB.

READ TABLE INTTAB INDEX 1.

VBELN = INTTAB-VALUE.

UNPACK VBELN TO VBELN.

READ TABLE INTTAB INDEX 2.

DEST_CTRY = INTTAB-VALUE.

READ TABLE INTTAB INDEX 3.

ORDER = INTTAB-VALUE.

UNPACK ORDER TO ORDER.

  • CHANGES MADE ON .

READ TABLE INTTAB INDEX 4.

ITEM = INTTAB-VALUE.

UNPACK ITEM TO ITEM.

  • CHANGES MADE ON .

  • REFRESH INTTAB.

  • CLEAR INTTAB.

*

  • LOOP AT INTTAB.

*

  • IF SY-TABIX = 1.

  • VBELN = INTTAB-VALUE.

*

  • ELSEIF SY-TABIX = 2.

  • DEST_CTRY = INTTAB-VALUE.

*

  • ELSEIF SY-TABIX = 3.

  • ORDER = INTTAB-VALUE.

*

  • ELSEIF SY-TABIX = 4.

  • ITEM = INTTAB-VALUE.

  • ENDIF.

*

  • ENDLOOP.

*

  • SELECT SINGLE * FROM VBAP WHERE VBELN = VBELN.

    • CHANGES MADE ON SIR 1959 : 10.08.2006.

CLEAR VBFA.

SELECT SINGLE * FROM VBFA WHERE VBELN = VBELN AND

VBTYP_V = 'C'.

****CHANGES MADE ON .

CLEAR VBEX.

SELECT SINGLE * FROM VBEX WHERE VBELN = VBFA-VBELV

AND POSNR = VBFA-POSNV.

****CHANGES MADE ON .

CLEAR EMBK.

SELECT SINGLE * FROM EMBK WHERE GENNR = VBEX-GENNR.

IF DEST_CTRY = 'US'.

CLEAR ZVBAK_BOCE.

SELECT SINGLE * FROM ZVBAK_BOCE WHERE VBELN = ORDER.

IF ZVBAK_BOCE-ZVEXPORTFL = 'X'.

IF EMBK-EXGEN IS INITIAL.

EMBK-EXGEN = 'N/R'.

ENDIF.

ELSE.

CLEAR EMBK-EXGEN.

ENDIF.

ELSE.

IF EMBK-EXGEN IS INITIAL.

EMBK-EXGEN = 'N/R'.

ENDIF.

ENDIF.

READ TABLE OUTTAB INDEX 1.

OUTTAB-VALUE = EMBK-EXGEN.

MODIFY OUTTAB INDEX 1.

ENDFORM. " LICENSE

my problem is here READ TABLE INTTAB INDEX 4.

ITEM = INTTAB-VALUE. is fetching only one item value its not going for secondtime into loop for second item.

can any one suggest me how to fetch no.of items for a one order

thnax

1 REPLY 1

Former Member
0 Kudos

Hi ,

Try out a different approach, this may help you out:

1. go to the print program .

2. search with the text element which contains the variable (used for printing lisence)in the form.

3. will will find the element in a write_form statement.

4. for that write form fn module find the loop...endloop.

5. declare a counter after the loop statement & assign it to 1.& increament it by 1 before endloop statement.

6. fetch the export lisence & store it in the variable which you pass to the form.

7 .check for counter = 1,

if sy-subrc <> 0.

free that variable.

pls donot use sy-tabix instead of counter.

Hope this will work.

Message was edited by: DIBYENDU BHATTACHARYYA