Skip to Content
0
Sep 10, 2007 at 04:07 AM

Adding Amount field in BSEG table and display it single line item?

483 Views

hi experts,

I am doing credit / debit form now my requirement is

According to BELNR , GJAHR,BUKRS i want to find credit amount for this selection cretiria.

so i want to add all the lines of amount filed for a particular BELNR and display it as single line.

so i am getting data from print program like this

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

SELECTION-SCREEN SKIP 2.

PARAMETERS: p_belnr LIKE bkpf-belnr OBLIGATORY,

p_bukrs LIKE bkpf-bukrs OBLIGATORY,

p_gjahr LIKE bkpf-gjahr OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b0.

SELECT SINGLE *

FROM bkpf

INTO i_bkpf

WHERE belnr = p_belnr

AND ( blart = 'DG' OR blart = 'ZG' )

AND bukrs = p_bukrs

AND gjahr = p_gjahr.

IF sy-subrc = 0.

SELECT *

FROM bseg

INTO table it_bseg

WHERE belnr = i_bkpf-belnr .

ENDIF.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'Z_CREDIT_DEBIT' " p_name

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

fm_name = v_form_name

  • EXCEPTIONS

  • NO_FORM = 1

  • NO_FUNCTION_MODULE = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION v_form_name

  • EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

i_bkpf = i_bkpf

i_bseg = i_bseg

  • EXCEPTIONS

  • FORMATTING_ERROR = 1

  • INTERNAL_ERROR = 2

  • SEND_ERROR = 3

  • USER_CANCELED = 4

  • OTHERS = 5

.

IF sy-subrc <> 0.

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

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

ENDIF.

so my I_BSEG containing all line items of particular BELNR . with the field SHKZG iam getting only credit line items .

now i want to do is add all credited amount and display like this in a table.

-


against ref# (BSEG-REBZG) ! details (BSEG-SGTXT)! amount

-


124569 10%discount 950.00(total amount ie sum of all lines amount for a BELNR)

10.00(total tax amt ie sum of all lines of tax amount for a BELNR)

-


960.00

-