Skip to Content
author's profile photo
Former Member

help me urgenz...

Hi all,

here i ve a problem for storing data into internal table, i.e in my report am calculating Opening balance for a GL account.

in my code i am using table gt_data for claculating O.bal, but here am storing that O.bal into variable 'result' .

its storing 1 value at a time. but now i want 2 store all O.balances into one internal table 'open_data' . how can i store these O.bal into internal table.

could anyone help me plz.....

my code is here...

REPORT ZBSR_GLITEMDISPLAY NO STANDARD PAGE HEADING. " LINE-SIZE 155 LINE-COUNT 30(3) .

      • table declaration ***

      TABLES: glt0, " G/L account master record transaction figures "#EC *

      bseg, " Accounting Document Segment for Line Items "#EC *

      bkpf. " Accounting Document Header "#EC *

          • DATA declaration ***

          DATA: count TYPE i,

          l_len(4) TYPE n,

          month(2) TYPE n,

          debit LIKE glt0-hslvt,

          credit LIKE glt0-hslvt,

          result LIKE glt0-hslvt.

          DATA: v_day(2) TYPE c,

          v_dat1 TYPE p, "#EC *

          v_mon(2) TYPE c,

          v_year(4) TYPE c,

          v_date LIKE sy-datum, "#EC NEEDED

          f_date TYPE sy-datum,

          l_date TYPE sydatum, "#EC NEEDED

          v_total LIKE bseg-dmbtr,

          sum0 LIKE glt0-hslvt,

          sum1 LIKE glt0-hslvt,

          sum2 LIKE glt0-hslvt,

          sum3 LIKE glt0-hslvt,

          add LIKE glt0-hslvt. "#EC *

              • BSEG table for Line Items for GL accounts.

              TYPES: BEGIN OF t_bseg,

              mandt LIKE bseg-mandt,

              bukrs LIKE bseg-bukrs, "comp code

              belnr LIKE bseg-belnr, "Accounting Document Number

              gjahr LIKE bseg-gjahr, "Fiscal year

              shkzg LIKE bseg-shkzg, "Debit / Credit indicator

              dmbtr LIKE bseg-dmbtr, "Amount in local currency

              pswsl LIKE bseg-pswsl,

              hkont LIKE bseg-hkont, "GL ac no

              END OF t_bseg.

              DATA : it_bseg TYPE STANDARD TABLE OF t_bseg WITH HEADER LINE.

              • WA_BSEG type T_BSEG.

                  • BKPF table for posting date

                  TYPES : BEGIN OF t_bkpf,

                  mandt TYPE bkpf-mandt,

                  bukrs TYPE bkpf-bukrs, "comp code

                  belnr TYPE bkpf-belnr, "Accounting Document Number

                  gjahr TYPE bkpf-gjahr, "Fiscal year

                  budat TYPE bkpf-budat, "Document type

                  END OF t_bkpf.

                  DATA : it_bkpf TYPE STANDARD TABLE OF t_bkpf WITH HEADER LINE.

                  • WA_BKPF LIKE it_BKPF.

                      • SKAT table for GL account Discription.

                      TYPES: BEGIN OF t_skat,

                      mandt TYPE mandt,

                      saknr TYPE saknr,

                      txt50 TYPE txt50,

                      END OF t_skat.

                      DATA: it_skat TYPE STANDARD TABLE OF t_skat WITH HEADER LINE.

                      • WA_SKAT LIKE IT_SKAT.

                      TYPES : BEGIN OF t_items,

                      mandt TYPE mandt,

                      hkont TYPE hkont,

                      incrdr(2),

                      bukrs TYPE bukrs,

                      belnr LIKE bseg-belnr,

                      shkzg TYPE shkzg,

                      dmbtr TYPE dmbtr,

                      pswsl TYPE pswsl,

                      budat TYPE budat,

                      txt50 TYPE txt50,

                      END OF t_items.

                      DATA : it_items TYPE STANDARD TABLE OF t_items WITH HEADER LINE,

                      wa_items TYPE t_items.

                      • GLT0 table for opening balance from 16 periods

                      DATA: BEGIN OF gt_data OCCURS 0 ,

                      rclnt LIKE glt0-rclnt,

                      bukrs LIKE glt0-bukrs,

                      drcrk LIKE glt0-drcrk,

                      ryear LIKE glt0-ryear,

                      racct LIKE glt0-racct,

                      hslvt LIKE glt0-hslvt,

                      hsl01 LIKE glt0-hsl01,

                      hsl02 LIKE glt0-hsl02,

                      hsl03 LIKE glt0-hsl03,

                      hsl04 LIKE glt0-hsl04,

                      hsl05 LIKE glt0-hsl05,

                      hsl06 LIKE glt0-hsl06,

                      hsl07 LIKE glt0-hsl07,

                      hsl08 LIKE glt0-hsl08,

                      hsl09 LIKE glt0-hsl09,

                      hsl10 LIKE glt0-hsl10,

                      hsl11 LIKE glt0-hsl11,

                      hsl12 LIKE glt0-hsl12,

                      hsl13 LIKE glt0-hsl13,

                      hsl14 LIKE glt0-hsl14,

                      hsl15 LIKE glt0-hsl15,

                      hsl16 LIKE glt0-hsl16,

                      start_balance LIKE glt0-hslvt,

                      end_balance LIKE glt0-hslvt,

                      END OF gt_data.

                      DATA: wa_gt_data LIKE gt_data OCCURS 0 WITH HEADER LINE. "#EC *

                      DATA: BEGIN OF open_data OCCURS 0 ,

                      racct LIKE glt0-racct,

                      open_balance LIKE glt0-hslvt,

                      close_balance LIKE glt0-hslvt,

                      END OF open_data.

                      DATA: wa_open_data LIKE open_data OCCURS 0 WITH HEADER LINE. "#EC *

                      ...selections.........................................................

                      SELECTION-SCREEN BEGIN OF BLOCK blk.

                      SELECT-OPTIONS: so_racct FOR glt0-racct, " NO INTERVALS NO-EXTENSION,

                      so_bukrs FOR glt0-bukrs NO INTERVALS NO-EXTENSION.

                      PARAMETERS: p_date LIKE sy-datum.

                      SELECTION-SCREEN END OF BLOCK blk.

                      AT SELECTION-SCREEN ON SO_RACCT.

                      IF SO_RACCT-LOW IS INITIAL.

                      MESSAGE E000(ZGLM).

                      ELSEIF GLT0-RACCT = SO_RACCT AND BSEG-ALTKT = SO_RACCT.

                      IF SY-SUBRC <> 0.

                      MESSAGE E001(ZGLM).

                      ENDIF.

                      ENDIF.

                      AT SELECTION-SCREEN ON SO_BUKRS.

                      if SO_BUKRS-LOW IS INITIAL.

                      MESSAGE E002(ZGLM).

                      ELSEIF BKPF-BUKRS = SO_BUKRS AND GLT0-BUKRS = SO_BUKRS.

                      IF SY-SUBRC <> 0.

                      MESSAGE E003(ZGLM).

                      ENDIF.

                      ENDIF.

                      AT SELECTION-SCREEN ON P_DATE.

                      v_day = '01'.

                      v_mon = p_date+4(2).

                      v_year = p_date+0(4).

                      concatenate v_year v_mon v_day into v_date.

                      IF p_date IS INITIAL.

                      MESSAGE E004(ZGLM).

                      • ELSEIF P_DATE > V_DATE.

                      • MESSAGE E005(ZGLM).

                      ENDIF.

                      START-OF-SELECTION.

                      v_day = '01'.

                      v_mon = p_date+4(2).

                      v_year = p_date+0(4).

                      CONCATENATE v_year v_mon v_day INTO v_date.

                      month = v_mon.

                      IF NOT p_date IS INITIAL.

                      CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'

                      EXPORTING

                      iv_date = p_date

                      IMPORTING

                      EV_MONTH_BEGIN_DATE = f_date

                      EV_MONTH_END_DATE = l_date.

                      ENDIF.

                      l_len = p_date+0(4).

                      CLEAR wa_gt_data.

                      SELECT rclnt

                      bukrs

                      drcrk

                      ryear

                      racct

                      hslvt

                      hsl01

                      hsl02

                      hsl03

                      hsl04

                      hsl05

                      hsl06

                      hsl07

                      hsl08

                      hsl09

                      hsl10

                      hsl11

                      hsl12

                      hsl13

                      hsl14

                      hsl15

                      hsl16

                      FROM glt0 INTO CORRESPONDING FIELDS OF TABLE gt_data

                      WHERE racct IN so_racct AND

                      bukrs IN so_bukrs AND

                      ryear = l_len.

                      LOOP AT gt_data INTO wa_gt_data. " WHERE racct = it_items-hkont.

                      CLEAR wa_gt_data-start_balance.

                      CASE month.

                      WHEN '00'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt.

                      PERFORM display_data.

                      WHEN '01'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt.

                      PERFORM display_data.

                      WHEN '02'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01.

                      PERFORM display_data.

                      WHEN '03'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02.

                      PERFORM display_data.

                      WHEN '04'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03.

                      PERFORM display_data.

                      WHEN '05'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04.

                      PERFORM display_data.

                      WHEN '06'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04 +

                      wa_gt_data-hsl05.

                      PERFORM display_data.

                      WHEN '07'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04 +

                      wa_gt_data-hsl05 +

                      wa_gt_data-hsl06.

                      PERFORM display_data.

                      WHEN '08'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04 +

                      wa_gt_data-hsl05 +

                      wa_gt_data-hsl06 +

                      wa_gt_data-hsl07.

                      PERFORM display_data.

                      WHEN '09'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04 +

                      wa_gt_data-hsl05 +

                      wa_gt_data-hsl06 +

                      wa_gt_data-hsl07 +

                      wa_gt_data-hsl08.

                      PERFORM display_data.

                      WHEN '10'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04 +

                      wa_gt_data-hsl05 +

                      wa_gt_data-hsl06 +

                      wa_gt_data-hsl07 +

                      wa_gt_data-hsl08 +

                      wa_gt_data-hsl09.

                      PERFORM display_data.

                      WHEN '11'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04 +

                      wa_gt_data-hsl05 +

                      wa_gt_data-hsl06 +

                      wa_gt_data-hsl07 +

                      wa_gt_data-hsl08 +

                      wa_gt_data-hsl09 +

                      wa_gt_data-hsl10.

                      PERFORM display_data.

                      WHEN '12'.

                      wa_gt_data-start_balance = wa_gt_data-hslvt +

                      wa_gt_data-hsl01 +

                      wa_gt_data-hsl02 +

                      wa_gt_data-hsl03 +

                      wa_gt_data-hsl04 +

                      wa_gt_data-hsl05 +

                      wa_gt_data-hsl06 +

                      wa_gt_data-hsl07 +

                      wa_gt_data-hsl08 +

                      wa_gt_data-hsl09 +

                      wa_gt_data-hsl10 +

                      wa_gt_data-hsl11.

                      wa_gt_data-end_balance = wa_gt_data-hsl13 +

                      wa_gt_data-hsl14 +

                      wa_gt_data-hsl15 +

                      wa_gt_data-hsl16.

                      MOVE wa_gt_data-end_balance TO sum3.

                      PERFORM display_data.

                      ENDCASE.

                      ENDLOOP.

                      &----


                      *& Form display_data

                      &----


                      • text

                      ----


                      FORM display_data.

                      IF wa_gt_data-drcrk = 'H'.

                      debit = debit + wa_gt_data-start_balance.

                      ELSE.

                      credit = credit + wa_gt_data-start_balance.

                      ENDIF.

                      result = debit + credit. " here am storing O.bal into result

                      ENDFORM. "display_data

                      Thanks & Regards,

                      sudharsan.

                      Add comment
                      10|10000 characters needed characters exceeded

                      • Follow
                      • Get RSS Feed

                      2 Answers

                      • author's profile photo
                        Former Member
                        Posted on Sep 28, 2007 at 03:26 AM

                        Add one more field to your internal table GT_DATA with name OPEN_BAL.

                        In your LOOP - ENDLOOP, assign this RESULT value to this field and then modify internal table record. In this way, you will have Open Balance for all entries of GT_DATA.

                        Add comment
                        10|10000 characters needed characters exceeded

                        • Former Member Former Member

                          I thought with every loop pass you will create RESULT, DEBIT and CREDIT values. Are you processing each record independently or is there any relation in internal table records - like while doing calculation for 2nd record, you will also consider first record value, so on and so forth.

                      • author's profile photo
                        Former Member
                        Posted on Sep 28, 2007 at 05:07 AM

                        Hi

                        You can declare an internal table with field result.After getting each result value appen it to the internal table.In the last all the 10 values will be there in the internal table.

                        Reward if useful.

                        Regards

                        Shibin

                        Add comment
                        10|10000 characters needed characters exceeded