Application Development and Automation 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: 
Read only

Problem with Checkox in Classical Report.

Former Member
0 Likes
1,061

Hi Friends,

My Requirement is : based on the company code and the purchasing document in the selection screen i am selecting ( ebeln , lifnr , bedat , bsart ) , from EKKO and ebeln, ebelp , effwr , from EKPO .

In my out put I am dispalying header fields and first field is check box.

and i kept 'SUBTOTAL' button on application tool bar.

when ever i select the check box of header those particular items should be loop and need to disaply subtotal for effwr.

Here i am getting problem while displaying subtotal . check box is not working properly.

Please look into my issue once.

Thanks in Advance,

Laxmi.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,024

Hi,

The checkbox that you are displaying should be one of the fields of the internal table that you are using to display the fields then at user-command when the user checks a couple of lines and clicks on subtotal just loop on the lines where the chckbox is checked and calculate the variable for subtotal and then once again write the report this time also write the variable for subtotals like below:

suppose itab is your internal table with data the first field here is a checkbox so


end-of-selection.
perform write_details.

form write_details.
loop at itab.
write:/ itab-checkbox as checkbox centered,
           itab-ebeln,
           itab-lifnr,
          ------so on
endloop.
if not  lv_subtotal is initial.
write:lv_subtotal.
endif.
endform.

then after selecting the checkbox the user clicks the subtotals button


at user-command.
case sy-ucomm.
when 'SUBTOTAL'.
 loop at itab where checkbox = 'X'.
  lv_subtotal = itab effwr + lv_subtotal.
endloop.
endcase.
perform write_report.

Regards,

Himanshu

Hi Friends,

My Requirement is : based on the company code and the purchasing document in the selection screen i am selecting ( ebeln , lifnr , bedat , bsart ) , from EKKO and ebeln, ebelp , effwr , from EKPO .

In my out put I am dispalying header fields and first field is check box.

and i kept 'SUBTOTAL' button on application tool bar.

when ever i select the check box of header those particular items should be loop and need to disaply subtotal for effwr.

Here i am getting problem while displaying subtotal . check box is not working properly.

Please look into my issue once.

Thanks in Advance,

Laxmi.

8 REPLIES 8
Read only

Former Member
0 Likes
1,024

Hi Laxmi,

As per my understanding, your requirement is below.

1. You are displaying EKKO data with check box as first field

2. you will select some purchase orders by clicking check boxes

3. You will press button SUBTOTAL

4. Now you have to capture the selected purchase orders (using check boxes) and for those purchase orders calculate subtotal of EFFWR field of EKPO

5. You will display the Purchase orders and subtotals in next screen.

Am i correct?

If yes, In the AT USER-COMMAND event, you have to write logic to capture SUBTOTAL button and loop at EKPO data and claculate sub totals. capture totals into new internal table and display.

Thanks,

Jyothi

Read only

0 Likes
1,024

Hi Jyothi,

Thank you for your quick response.

what you understood is right.

I am doing the calculation part in at usercommand. but check box is not working..

here i am giving my sample code . Please check it once.

&----


*& Report ZL_SAM26

*&

&----


*&

*&

&----


REPORT ZL_SAM26 no STANDARD PAGE HEADING line-SIZE 45.

TYPES : BEGIN OF ty_ekko,

check1,

bukrs type bukrs,

ebeln type ebeln,

lifnr type elifn,

bedat TYPE ebdat,

bsart TYPE esart,

end of ty_ekko.

TYPES : BEGIN OF ty_ekpo,

bukrs type bukrs,

ebeln type ebeln,

ebelp type EBELP,

effwr type effwr,

end of ty_ekpo.

Data : it_ekko type table of ty_ekko,

w_ekko type ty_ekko,

it_ekpo type table of ty_ekpo,

w_ekpo type ty_ekpo,

check1 TYPE c ,

v_ebeln type ekko-ebeln,

V1 TYPE EFFWR,

v2 type ebeln.

SELECTION-SCREEN :BEGIN OF block b1 WITH FRAME Title text-001.

parameter p_bukrs type ekko-bukrs.

SELECT-OPTIONS s_ebeln FOR v_ebeln OBLIGATORY.

SELECTION-SCREEN END OF block b1.

START-OF-SELECTION.

SELECT bukrs

ebeln

lifnr

bedat

bsart

from ekko

into TABLE it_ekko

where bukrs = p_bukrs

and ebeln in s_ebeln.

SELECT bukrs

ebeln

ebelp

effwr

from ekpo

into table it_ekpo

for all entries in it_ekko

where bukrs = it_ekko-bukrs

and ebeln = it_ekko-ebeln.

END-OF-SELECTION.

LOOP AT it_ekko into w_ekko.

write : / check1 AS CHECKBOX ,

w_ekko-ebeln ,

w_ekko-bukrs ,

w_ekko-lifnr ,

w_ekko-bedat ,

w_ekko-bsart.

ENDLOOP.

uline.

loop at it_ekpo into w_ekpo.

write : / w_ekpo-ebeln , w_ekpo-ebelp, w_ekpo-effwr.

ENDLOOP.

SET PF-STATUS 'LAXMI'.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

WHEN 'SEETOTAL'.

PERFORM CALCULATIONS.

ENDCASE.

&----


*& Form CALCULATIONS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CALCULATIONS .

LOOP at it_ekko into w_ekko WHERE check1 = 'X'.

v2 = w_ekko-ebeln.

loop at it_ekpo into w_ekpo where ebeln = v2.

V1 = w_ekpo-effwr + V1.

write : / w_ekpo-ebeln , w_ekpo-ebelp, w_ekpo-effwr.

ENDLOOP.

ULINE .

WRITE : /18 V1.

uline.

ENDLOOP.

ENDFORM. " CALCULATIONS

Thanks ,

Laxmi.

Read only

Former Member
0 Likes
1,025

Hi,

The checkbox that you are displaying should be one of the fields of the internal table that you are using to display the fields then at user-command when the user checks a couple of lines and clicks on subtotal just loop on the lines where the chckbox is checked and calculate the variable for subtotal and then once again write the report this time also write the variable for subtotals like below:

suppose itab is your internal table with data the first field here is a checkbox so


end-of-selection.
perform write_details.

form write_details.
loop at itab.
write:/ itab-checkbox as checkbox centered,
           itab-ebeln,
           itab-lifnr,
          ------so on
endloop.
if not  lv_subtotal is initial.
write:lv_subtotal.
endif.
endform.

then after selecting the checkbox the user clicks the subtotals button


at user-command.
case sy-ucomm.
when 'SUBTOTAL'.
 loop at itab where checkbox = 'X'.
  lv_subtotal = itab effwr + lv_subtotal.
endloop.
endcase.
perform write_report.

Regards,

Himanshu

Read only

0 Likes
1,024

Hi Himanshu,

Thank you for your reply.

I have done as the same way. Please check my code once.

Thanks ,

Laxmi.

Read only

0 Likes
1,024

hai,

If your problem still not solved, run given below program, May be helpful for you.

DATA: box(1) TYPE c, lines TYPE i, num(1) TYPE c.

SET PF-STATUS 'CHECK'.

DO 5 TIMES.
  num = sy-index.
  WRITE: / box AS CHECKBOX, 'Line', num.
  HIDE: box, num.
ENDDO.
lines = sy-linno.

TOP-OF-PAGE.
  WRITE  'Select some checkboxes'.
  ULINE.

AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN 'READ'.
      SET PF-STATUS 'CHECK' EXCLUDING 'READ'.
      box = space.
      DO lines TIMES.
        READ LINE sy-index FIELD VALUE box.
        IF box = 'X'.
          WRITE: / 'Line', num, 'was selected'.
          box = space.
          MODIFY LINE sy-index
                      FIELD VALUE  box
                      FIELD FORMAT box INPUT OFF
                                   num COLOR 6 INVERSE ON.
        ENDIF.
      ENDDO.
  ENDCASE.

Read only

Former Member
0 Likes
1,024

HI,

You can achieve this even without the Checkbox, just use the key word

GET CURSOR FIELD fnam VALUE fval in the AT LINE-SELECTION event.

before this you need to use the HIDE statement with in the loop where you are using the WRITE statement.

As you do this you can get the value at Header Level.

Hope this will serve your purpose.

Cheers

Ramchander Rao.K

Read only

Former Member
0 Likes
1,024

Hi Laxmi ..

Modify ur code at user command as follows.....


REPORT ZL_SAM26 no STANDARD PAGE HEADING line-SIZE 45.
 TYPES : BEGIN OF ty_ekko,
           check1,
           bukrs type ekko-bukrs,
           ebeln type ekko-ebeln,
           lifnr type ekko-lifnr,
           bedat TYPE ekko-bedat,
           bsart TYPE ekko-bsart,
         end of ty_ekko.
TYPES :
    BEGIN OF ty_ekpo,
       bukrs type bukrs,
       ebeln type ebeln,
       ebelp type EBELP,
       effwr type effwr,
       end of ty_ekpo.
Data : it_ekko type table of ty_ekko,
       w_ekko type ty_ekko,
       it_ekpo type table of ty_ekpo,
       w_ekpo type ty_ekpo,
       check1 TYPE c ,
       v_ebeln type ekko-ebeln,
       V1 TYPE EFFWR,
       v2 type ebeln.

       SELECTION-SCREEN :BEGIN OF block b1 WITH FRAME Title text-001.
         parameter p_bukrs type ekko-bukrs.
         SELECT-OPTIONS s_ebeln FOR v_ebeln OBLIGATORY.
       SELECTION-SCREEN END OF block b1.

START-OF-SELECTION.
       SELECT bukrs  ebeln lifnr bedat  bsart from ekko
          into corresponding fields of TABLE it_ekko
          where bukrs = p_bukrs
          and ebeln in s_ebeln.
SELECT bukrs ebeln ebelp effwr from ekpo
  into table it_ekpo
  for all entries in it_ekko
  where bukrs = it_ekko-bukrs
  and ebeln = it_ekko-ebeln.

END-OF-SELECTION.

LOOP AT it_ekko into w_ekko.
  write : / check1 AS CHECKBOX ,
            w_ekko-ebeln ,
            w_ekko-bukrs ,
            w_ekko-lifnr ,
            w_ekko-bedat ,
            w_ekko-bsart.
  ENDLOOP.
  uline.
 loop at it_ekpo into w_ekpo.
   write:/ w_ekpo-ebeln ,
            w_ekpo-ebelp,
            w_ekpo-effwr.
ENDLOOP.

  SET PF-STATUS 'STAT'.
  AT USER-COMMAND.
     CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
           LEAVE TO SCREEN 0.
        WHEN 'SEETOTAL'.
        PERFORM CALCULATIONS.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form CALCULATIONS
*&---------------------------------------------------------------------*
 FORM CALCULATIONS .
 data: w_lines type i.
 describe table it_ekko lines w_lines.
 if sy-lsind = 1.
  do w_lines times.
  read line sy-index
  field value check1
              w_ekko-ebeln
              w_ekko-bukrs
              w_ekko-lifnr
              w_ekko-bedat
              w_ekko-bsart.
  if check1 eq 'X'.
   v2 = w_ekko-ebeln.
     loop at it_ekpo into w_ekpo where ebeln = v2.
       V1 = w_ekpo-effwr + V1.
       write : / w_ekpo-ebeln , w_ekpo-ebelp,w_ekpo-effwr.
     ENDLOOP.
     ULINE .
     WRITE : /18 V1. uline.
  endif.
  enddo.
 endif.
ENDFORM. " CALCULATIONs

Hope it helps.....

Regards

Read only

0 Likes
1,024

Hi Laxmi,

You are not doing anything to capture the checkbox. The check box value will not update automatically into internal table. Follow the way specified by Malik or deeba. It will work.

Thanks,

Jyothi