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: 

abap fgs report

Former Member
0 Kudos

hi guru's,

i have a problem with my code can anyone help me out with this,actually i am fetching invoice quantity from vbrp based on sales order (vbeln and posnr).actually i have 3 line items in sales order. but they invoce for this particular sales order is done seperately by dividing it into two. say in first invoice they have taken 3 quantity each from each line item and in second invoice they haive taken rest of it.so i need to get the invoice quantity updated each time the invoice is done for that particular sales order. i have written a code for it but the problem is i am getting all they invoce quantity in internal table it_vbrp but its moving only the first invoice item to final internal table it_final.please can anyone help me out with this code what statement i should write in this code to update my invoice quantity at end while moving it into final irrespective of invoice generated.my code is as follows, please help me out,

IF NOT IT_FINAL[] IS INITIAL.

SORT IT_FINAL BY VBELN.

SELECT FKIMG VBELN AUBEL POSNR FROM VBRP INTO CORRESPONDING FIELDS OF TABLE IT_VBRP

FOR ALL ENTRIES IN IT_FINAL WHERE AUBEL = IT_FINAL-VBELN.

ENDIF.

IF NOT IT_VBRP[] IS INITIAL.

SORT IT_VBRP BY AUBEL POSNR.

LOOP AT IT_FINAL.

WA_TABIX = SY-TABIX.

READ TABLE IT_VBRP WITH KEY AUBEL = IT_FINAL-VBELN POSNR = IT_FINAL-POSNR BINARY SEARCH.

IF SY-SUBRC = 0.

IT_FINAL-FKIMG = IT_VBRP-FKIMG.

MODIFY IT_FINAL INDEX WA_TABIX TRANSPORTING FKIMG.

ENDIF.

ENDLOOP.

ENDIF.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Abhinash,

Since the whole code and internal tables information is not available i am suggesting a solution on the basis of what i have understood.

The code you have shown seems to be ok if It_final contains all order-items.

Now since its not working ts difficult to suggest code unless we zero down on error.

I would suggest you to put a break-point at read table it_vbrp statement and check if it is able to get the entry for the second line item or not. And if it then check the modify statement if the changes are getting reflected in the final table or not.

revert with these clarifications so that i can suggest some different code.

<b>Always reward points to useful suggestions.</b>

regards,

Vikas

7 REPLIES 7

Former Member
0 Kudos

Hi Abhinash,

Since the whole code and internal tables information is not available i am suggesting a solution on the basis of what i have understood.

The code you have shown seems to be ok if It_final contains all order-items.

Now since its not working ts difficult to suggest code unless we zero down on error.

I would suggest you to put a break-point at read table it_vbrp statement and check if it is able to get the entry for the second line item or not. And if it then check the modify statement if the changes are getting reflected in the final table or not.

revert with these clarifications so that i can suggest some different code.

<b>Always reward points to useful suggestions.</b>

regards,

Vikas

0 Kudos

thanks vikas for ur interest, but if u wanr me to send the complete code will do that but this code is working fine if a single sales order has a single invoice but if a sales order has multiple invoice split into more than one than the quantity should be updated,that is not working its showing only the first invoice in final but the internal table contains all the invoice items related to sales order. so if you could send me your email id i coulsd send you the complete code.i hope you dnt mind , i hope am not disturbing you rite.

0 Kudos

Hi Abhinash, here's the code, you need to make some changes in the code which you had given initially.

hope this solves your issue.

<b>Do reward Points to all helpful answers.</b>

regards,

vikas

TABLES : vbap, vbak, vbkd, mbew , makt , mard.

TYPE-POOLS: slis.

*

INCLUDE icons.

DATA : BEGIN OF it_final OCCURS 0,

vbeln LIKE vbap-vbeln,

posnr LIKE vbap-posnr,

matnr LIKE vbap-matnr,

werks LIKE vbap-werks,

kwmeng LIKE vbap-kwmeng,

kdmat LIKE vbap-kdmat,

waerk LIKE vbak-waerk,

fkimg LIKE vbrp-fkimg,

zterm LIKE vbkd-zterm,

fkdat LIKE vbkd-fkdat,

bstdk LIKE vbkd-bstdk,

bstkd LIKE vbkd-bstkd,

vsart LIKE vbkd-vsart,

lddat LIKE vbep-lddat,

bezei LIKE t173t-bezei,

labst LIKE mard-labst,

maktx LIKE makt-maktx,

bqty LIKE vbrp-fkimg,

status(4),

END OF it_final.

DATA: BEGIN OF it_vbkd OCCURS 0,

vsart LIKE vbkd-vsart,

zterm LIKE vbkd-zterm,

fkdat LIKE vbkd-fkdat,

bstdk LIKE vbkd-bstdk,

bstkd LIKE vbkd-bstkd,

vbeln LIKE vbkd-vbeln,

posnr LIKE vbkd-posnr,

END OF it_vbkd.

DATA: BEGIN OF it_vbep OCCURS 0,

lddat LIKE vbep-lddat,

vbeln LIKE vbep-vbeln,

posnr LIKE vbep-posnr,

END OF it_vbep.

DATA: BEGIN OF it_mard OCCURS 0,

labst LIKE mard-labst,

matnr LIKE mard-matnr,

werks LIKE mard-werks,

END OF it_mard.

DATA: BEGIN OF it_makt OCCURS 0,

maktx LIKE makt-maktx,

matnr LIKE makt-matnr,

END OF it_makt.

DATA: BEGIN OF it_vbrp OCCURS 0,

aubel LIKE vbrp-aubel,

posnr LIKE vbrp-posnr,

fkimg LIKE vbrp-fkimg,

vbeln LIKE vbrp-vbeln,

vgbel LIKE vbrp-vgbel, "NEW FIELD ADDED

END OF it_vbrp.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

g_repid LIKE sy-repid,

i_header TYPE slis_t_listheader.

DATA: gt_events TYPE slis_t_event,

gt_list_top_of_page TYPE slis_t_listheader,

g_status_set TYPE slis_formname VALUE 'PF_STATUS_SET',

g_user_command TYPE slis_formname VALUE 'USER_COMMAND',

g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',

g_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST',

g_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.

DATA:wa_tabix LIKE sy-tabix.

INITIALIZATION.

g_repid = sy-repid.

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .

SELECT-OPTIONS : s_vbeln FOR vbap-vbeln.

SELECTION-SCREEN:SKIP 2.

SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS: rad1 RADIOBUTTON GROUP rad ,

rad2 RADIOBUTTON GROUP rad DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN : END OF BLOCK b1.

PERFORM eventtab_build USING gt_events[].

*START-OF-SELECTION .

START-OF-SELECTION .

PERFORM fetch_data .

PERFORM built_fieldcat.

PERFORM comment_build USING gt_list_top_of_page[].

PERFORM display.

*END-OF-SELECTION.

END-OF-SELECTION.

&----


*& Form FETCH_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fetch_data .

SELECT vbak~waerk

vbap~vbeln

vbap~posnr

vbap~matnr

vbap~kwmeng

vbap~kdmat

vbap~werks INTO CORRESPONDING FIELDS OF TABLE it_final

FROM vbak INNER JOIN vbap ON vbakvbeln = vbapvbeln

WHERE vbak~vbeln IN s_vbeln.

  • **********************************************************************************************************************

IF NOT it_final[] IS INITIAL.

SORT it_final BY matnr.

SELECT labst matnr werks FROM mard INTO CORRESPONDING FIELDS OF TABLE it_mard

FOR ALL ENTRIES IN it_final WHERE matnr = it_final-matnr

AND werks = it_final-werks.

ENDIF.

IF NOT it_mard[] IS INITIAL.

SORT it_mard BY matnr.

LOOP AT it_final.

wa_tabix = sy-tabix.

READ TABLE it_mard WITH KEY matnr = it_final-matnr BINARY SEARCH.

IF sy-subrc = 0.

it_final-labst = it_mard-labst.

MODIFY it_final INDEX wa_tabix TRANSPORTING labst.

ENDIF.

ENDLOOP.

ENDIF.

  • **********************************************************************************************************************

  • **********************************************************************************************************************

IF NOT it_final[] IS INITIAL.

SORT it_final BY vbeln posnr.

SELECT vbeln posnr lddat FROM vbep INTO CORRESPONDING FIELDS OF TABLE it_vbep

FOR ALL ENTRIES IN it_final WHERE vbeln = it_final-vbeln

AND posnr = it_final-posnr.

ENDIF.

IF NOT it_vbep[] IS INITIAL.

SORT it_vbep BY vbeln posnr.

LOOP AT it_final.

wa_tabix = sy-tabix.

READ TABLE it_vbep WITH KEY vbeln = it_final-vbeln posnr = it_final-posnr BINARY SEARCH.

IF sy-subrc = 0.

it_final-lddat = it_vbep-lddat.

MODIFY it_final INDEX wa_tabix TRANSPORTING lddat.

ENDIF.

ENDLOOP.

ENDIF.

  • **********************************************************************************************************************

IF NOT it_final[] IS INITIAL.

SORT it_final BY matnr.

SELECT maktx matnr FROM makt INTO TABLE it_makt

FOR ALL ENTRIES IN it_final WHERE matnr = it_final-matnr.

ENDIF.

IF NOT it_makt[] IS INITIAL.

SORT it_makt BY matnr.

LOOP AT it_final.

wa_tabix = sy-tabix.

READ TABLE it_makt WITH KEY matnr = it_final-matnr BINARY SEARCH.

IF sy-subrc = 0.

it_final-maktx = it_makt-maktx.

it_final-matnr = it_makt-matnr.

MODIFY it_final INDEX wa_tabix TRANSPORTING maktx matnr labst.

ENDIF.

ENDLOOP.

ENDIF.

  • **********************************************************************************************************************

IF NOT it_final[] IS INITIAL.

SORT it_final BY vbeln.

SELECT fkdat vsart zterm bstkd bstdk vbeln posnr FROM vbkd INTO CORRESPONDING FIELDS OF TABLE it_vbkd

FOR ALL ENTRIES IN it_final WHERE vbeln = it_final-vbeln

AND vbeln IN s_vbeln.

ENDIF.

IF NOT it_vbkd[] IS INITIAL.

SORT it_vbkd BY vbeln.

LOOP AT it_final.

wa_tabix = sy-tabix.

READ TABLE it_vbkd WITH KEY vbeln = it_final-vbeln BINARY SEARCH.

IF sy-subrc = 0.

it_final-fkdat = it_vbkd-fkdat.

it_final-vsart = it_vbkd-vsart.

it_final-zterm = it_vbkd-zterm.

it_final-bstkd = it_vbkd-bstkd.

it_final-bstdk = it_vbkd-bstdk.

MODIFY it_final INDEX wa_tabix TRANSPORTING fkdat vsart zterm bstkd bstdk.

ENDIF.

ENDLOOP.

ENDIF.

*********************************************************************************************************************

IF NOT it_final[] IS INITIAL.

SORT it_final BY vbeln posnr.

LOOP AT it_final.

it_final-bqty = it_final-kwmeng - it_final-fkimg.

IF it_final-bqty EQ 0.

it_final-status = icon_green_light.

ELSE.

it_final-status = icon_red_light.

MODIFY it_final INDEX wa_tabix TRANSPORTING bqty status.

ENDIF.

MODIFY it_final.

ENDLOOP.

ENDIF.

  • **********************************************************************************************************************

IF NOT it_final[] IS INITIAL.

DATA v_pos TYPE vbrp-posnr.

SORT it_final BY vbeln posnr.

SELECT fkimg vbeln aubel posnr vgbel FROM vbrp INTO CORRESPONDING FIELDS OF TABLE it_vbrp

FOR ALL ENTRIES IN it_final WHERE aubel = it_final-vbeln.

ENDIF.

IF NOT it_vbrp[] IS INITIAL.

SORT it_vbrp BY aubel posnr vgbel.

LOOP AT it_vbrp.

AT NEW aubel.

CLEAR wa_tabix.

CLEAR v_pos.

ENDAT.

READ TABLE it_final WITH KEY vbeln = it_vbrp-aubel

posnr = it_vbrp-posnr.

  • FKDAT = IT_VBRP-ERDAT BINARY SEARCH.

IF sy-subrc = 0 AND v_pos < it_vbrp-posnr.

it_final-fkimg = it_vbrp-fkimg.

MODIFY TABLE it_final FROM it_final TRANSPORTING fkimg.

wa_tabix = sy-tabix + 1.

ELSE.

it_final-fkimg = it_vbrp-fkimg.

INSERT it_final INDEX wa_tabix.

wa_tabix = wa_tabix + 1.

ENDIF.

v_pos = it_vbrp-posnr.

ENDLOOP.

ENDIF.

  • **********************************************************************************************************************

ENDFORM. " FETCH_DATA

&----


*& Form BUILT_FIELDCAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM built_fieldcat .

wa_fieldcat-fieldname = 'POSNR'.

wa_fieldcat-col_pos = '1'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Item No'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'VBELN'.

wa_fieldcat-col_pos = '2'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'S.O Number'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'BSTKD'.

wa_fieldcat-col_pos = '3'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Cust Po Number'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'BSTDK'.

wa_fieldcat-col_pos = '4'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Cust Po Date'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-col_pos = '5'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Mat.Number'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MAKTX'.

wa_fieldcat-col_pos = '6'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Mat Desc'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'FKDAT'.

wa_fieldcat-col_pos = '7'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Date Needed By Cust'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'KWMENG'.

wa_fieldcat-col_pos = '8'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Order Qty'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'FKIMG'.

wa_fieldcat-col_pos = '9'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Inv Qty'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'BQTY'.

wa_fieldcat-col_pos = '10'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Balance Qnty'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'LABST'.

wa_fieldcat-col_pos = '11'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Stock Available'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'KDMAT'.

wa_fieldcat-col_pos = '12'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Cust Mat.Number'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'LDDAT'.

wa_fieldcat-col_pos = '13'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'Shipping Date'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'STATUS'.

wa_fieldcat-col_pos = '14'.

wa_fieldcat-tabname = 'IT_FINAL'.

wa_fieldcat-seltext_l = 'STATUS'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " BUILT_FIELDCAT

*

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display .

IF rad1 = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

it_fieldcat = it_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_final

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ELSEIF rad2 = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = g_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = it_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'A'

  • IS_VARIANT =

it_events = gt_events[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_final

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDIF.

ENDFORM. " DISPLAY

&----


*& Form EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM eventtab_build USING rt_events TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = rt_events.

READ TABLE rt_events WITH KEY name = slis_ev_top_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE g_top_of_page TO ls_event-form.

APPEND ls_event TO rt_events.

ENDIF.

ENDFORM. "EVENTTAB_BUILD

&----


*& Form TOP_OF_PAGE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

i_logo = 'LOGO'

it_list_commentary = gt_list_top_of_page.

ENDFORM. "TOP_OF_PAGE

&----


*& Form COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

CLEAR ls_line.

ls_line-typ = 'H'.

  • LS_LINE-KEY: NOT USED FOR THIS TYPE

ls_line-info = 'Finished Goods Report'.

APPEND ls_line TO lt_top_of_page.

  • STATUS LINE: TYPE S

CLEAR ls_line.

  • LS_LINE-TYP = 'S'.

    • LS_LINE-KEY = 'TEXT100'.

    • LS_LINE-INFO = 'TEXT101'.

  • APPEND LS_LINE TO LT_TOP_OF_PAGE.

  • LS_LINE-KEY = TEXT-103.

  • LS_LINE-INFO = TEXT-104.

  • APPEND LS_LINE TO LT_TOP_OF_PAGE.

    • ACTION LINE: TYPE A

  • CLEAR LS_LINE.

  • LS_LINE-TYP = 'A'.

    • LS_LINE-KEY: NOT USED FOR THIS TYPE

  • LS_LINE-INFO = TEXT-105.

  • APPEND LS_LINE TO LT_TOP_OF_PAGE.

ENDFORM. "COMMENT_BUILD

Message was edited by:

Vikas Taneja

0 Kudos

HI vikas,

this code is really helpful but its not complete now its reading all the invoice quantity. but its not summing them up. actually it should add up the quantity individally that means it should add up the quantity of item number 10 and then 20 and so on individually and should produce that quantity against each line item.i hope i was clear on my requirement.

thanks.

0 Kudos

HI vikas ,

i have changed my code its reading all the quantity but i need to add up the invoice quantity against each line item. how should i write this please help regarding this issue my code is as follows.

IF NOT IT_FINAL[] IS INITIAL.

DATA: V_POS TYPE VBRP-POSNR.

SORT IT_FINAL BY VBELN POSNR.

SELECT FKIMG VBELN AUBEL POSNR VGBEL FROM VBRP INTO CORRESPONDING FIELDS OF TABLE IT_VBRP

FOR ALL ENTRIES IN IT_FINAL WHERE AUBEL = IT_FINAL-VBELN.

ENDIF.

IF NOT IT_VBRP[] IS INITIAL.

SORT IT_VBRP BY AUBEL POSNR VGBEL.

LOOP AT IT_VBRP.

AT NEW AUBEL.

CLEAR WA_TABIX.

CLEAR V_POS.

ENDAT.

READ TABLE IT_FINAL WITH KEY VBELN = IT_VBRP-AUBEL POSNR = IT_VBRP-POSNR.

IF SY-SUBRC = 0 AND V_POS < IT_VBRP-POSNR.

IT_FINAL-FKIMG = IT_VBRP-FKIMG.

MODIFY TABLE IT_FINAL FROM IT_FINAL TRANSPORTING FKIMG.

WA_TABIX = SY-TABIX + 1.

ELSE.

IT_FINAL-FKIMG = IT_VBRP-FKIMG.

INSERT IT_FINAL INDEX WA_TABIX.

WA_TABIX = WA_TABIX + 1.

ENDIF.

V_POS = IT_VBRP-POSNR.

ENDLOOP.

ENDIF.

0 Kudos

Hi Abinash,

If i have understood the problem right, you need the total invoiced quantity against each line item of all the orders.

For this you do not have to code and rather can use the function provided by the alv tools.

In report first perform the following operations:

1. sort operation on the Order field of the list

2. then the summation operation on the invoiced quantity field.

3. then select order, item and invoiced quantity in this mentioned order and click Subtotal icon you will get the result you desire.

Hope this solves your issue.

<b>Always reward points to useful suggestions.</b>

regards,

Vikas

Message was edited by:

Vikas Taneja

Message was edited by:

Vikas Taneja

0 Kudos

hi vikas ,

its was not exactly that but anyways you code helped me a lot and i was able to figure it out the further requirement. i was supposed to display the total invoice quantity at my output .it solved my problem. thanks a lot. i have written a small portion of code after that. and i was able to solve it.

this was the code i added to that.

LOOP AT IT_VBRP.

MOVE IT_VBRP-AUBEL TO w_diff-AUBEL.

MOVE IT_VBRP-POSNR TO w_diff-POSNR.

MOVE IT_VBRP-FKIMG TO w_diff-FKIMG.

COLLECT W_DIFF INTO IT_DIFF .

ENDLOOP.

IF NOT IT_diff[] IS INITIAL.

SORT IT_diff BY AUBEL POSNR.

LOOP AT IT_FINAL." INTO W_FINAL.

WA_tabix = sy-tabix.

READ TABLE IT_diff INTO W_DIFF WITH KEY AUBEL = IT_FINAL-VBELN POSNR = IT_FINAL-POSNR.

IF sy-subrc EQ 0.

IT_FINAL-POSNR = w_diff-POSNR.

IT_FINAL-FKIMG = w_diff-FKIMG.

MODIFY IT_FINAL INDEX WA_TABIX TRANSPORTING POSNR FKIMG.

ENDIF.

ENDLOOP.

ENDIF.