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

Having issue with Table control.

Former Member
0 Likes
6,002

Dear all,

I have created a table control, and in that i am adding the details on the 1st screen and the data needs to be saved on the 2nd screen.1st Screen is like this.

Now with this i am updating the data on the second screen. But in my case if i have updated the data once, its not updating the next record in the next line. its updating in the same line.

The very next line that i have added that is added like this.

Thanks and Regards

Jai

22 REPLIES 22
Read only

Former Member
0 Likes
5,963

Hi Jai,

Your table control data depends on how you append / insert data in the internal table.

If you have added as a new line at end using append in your output internal table for table control then it should bring as you expect. Debug and check how your data is sorted in the internal table that outputs data to your table. Check that and you should get an idea.

Thanks,

Naveen

Read only

0 Likes
5,963

Dear Naveen,

Kindly refer the below code that we have used to insert the data into final internal table.

SELECT * FROM zea_packaging

   INTO CORRESPONDING FIELDS OF TABLE it_zea_packaging1

   FOR ALL ENTRIES IN it_zea_packaging

   WHERE eorder = it_zea_packaging-eorder.

   data :flag type char3.

   LOOP AT it_main INTO wa_main WHERE mark = 'X'.

     flag = 0.

     LOOP AT it_zexp_advice1 INTO wa_zexp_advice1 WHERE eorder = wa_main-eorder.

       wa_main2-sr_no         = wa_zexp_advice1-sr_no.

       wa_main2-eorder        = wa_zexp_advice1-eorder.

       wa_main2-eano          = wa_zexp_advice1-eano.

       wa_main2-buyer         = wa_zexp_advice1-buyer.

       wa_main2-buyer_code    = wa_zexp_advice1-buyer_code.

       wa_main2-zprirority    = wa_zexp_advice1-zprirority.

       wa_main2-zplant        = wa_zexp_advice1-zplant.

       wa_main2-zdate          = wa_zexp_advice1-zdate.

       READ TABLE it_vbap INTO wa_vbap WITH KEY vbeln = wa_main-eorder .

       wa_main2-matnr         = wa_vbap-matnr.

       wa_main2-arktx         = wa_vbap-arktx.

       wa_main2-mark          = wa_vbap-mark.

       READ TABLE it_zea_packaging1 INTO wa_zea_packaging1 WITH KEY eorder = wa_main-eorder.

       IF flag = 0 and

          wa_main2-zprirority = wa_main1-zprirority and

          wa_main2-zplant = wa_main1-zplant and

          wa_main2-zdate = wa_main1-zdate and

          wa_zea_packaging1-zbal_qty is INITIAL  .

          wa_main2-tonnage      = wa_zea_packaging1-tonnage.

          wa_main2-zprocess_qty = wa_zea_packaging1-zprocess_qty.

          wa_main2-zbal_qty     = wa_zea_packaging1-zbal_qty.

       flag = 1.

       ENDIF.

       APPEND wa_main2 TO it_main2.

       CLEAR : wa_vbap ,wa_zexp_advice1, wa_zea_packaging1, wa_main2.


Thanks and Regards

Jai

Read only

0 Likes
5,963

Hi Jai,

Sorry I don't get it. Your code seems a bit confusing. What is the exact requirement of yours? Is it in hte first screen you add an entry which needs to be reflected in second screen? Where is this DB table ZEA_PACKAGING coming from and what role does it play here.

Regarding table control, in simple words what it is it just displays the data in the same sorting format that your output internal table contains.

Thanks,

Naveen

Read only

0 Likes
5,963

Dear Naveen,

Our requirement is, we have net weight on the 1st screen, that is coming from z-table. now in a plant i need to process some quantity of net weight. so quantity to be processed is the value that that we need to process in plant. and the balance quantity is net weight - minus quantity to be processed.

So requirement first we have processed some quantity, that should show on the second screen, and if next time we process some quantity, that should show on second line. and so on.

Thanks and Regards

Jai

Read only

0 Likes
5,963

Hi Jai,

so you mean something like a history i.e. whenever you change a quantity you need to add a new record with the value changed and something like that? Is that what your requirement is?

could you please provide some examples on what you do in first screen and what should be the desired result in second screen?

Thanks,

Naveen

Read only

0 Likes
5,963

Dear Naveen,

That is what our requirement.

Suppose, we have Net weight on the 1st screen is 2000 and we have entered quantity to be processed as 1000. so on the next screen,

Net Weight should be 2000,

Quantity to be processed  1000

and balance quantity  1000

If next time we open the first screen, Net weight should be same a 2000, if we enter 500 as quantity to be processed, then balance quantity should be 500.

so with the 1st line that we have added previously, with that these details should come in 2nd line,

with Net weight 2000, Balance Quantity as 500 and quantity to be processed as 500.

And so on.

Thanks and Regards

Jai

Read only

0 Likes
5,963

Hi Jai,

Then you just need to use append to the output internal table and the data should be coming as you require unless you haven't used an insert or you haven't used a sorted internal table.

Also double check in debugging how the internal table has the data.

Sadly I can't do much unless I see what is happening in debugging.

Thanks,

Naveen

Read only

0 Likes
5,963

Dear Naveen,

how i can show you the data in debugging mode.

Thanks and Regards

Jai

Read only

0 Likes
5,963

Dear Naveen,

i am having still one issue, i have resolved almost everything. Just see the below table control.

In that i need to calculate Balance quantity. and in this way i need to calculate the same.

9,080.00(Total Qty) - 1000.00(qty to be procressed) = 8080 (Balance Qty) Next Line

8,080.00(Total Qty) - 1500.00(qty to be procressed) = 6580 (balance Qty) Next Line

6,580.00(total Qty) - 700.00(Qty to be procressed)  = 5880(Balance Qty) Next Line

5880.00(total Qty) - 900.00 (qty to be processed) = 4980(Balance Qty) and so on.

How to achieve this.

Kindly suggest.

Thanks and Regards

Jai

Read only

0 Likes
5,963

My code id deducting the quantity from the first value every time.

Read only

0 Likes
5,963

Hi Jai,

You can try the logic something like below:

Loop at ITAB.

if sy-tabix <> 1.

itab-total = lv_balance.

modify itab transporting total.

endif.

lv_balance = itab-total - itab-qtytobeprocessed

Endloop.

Thanks,

Naveen

Read only

0 Likes
5,963

Dear Naveen,

I have written code to display the data is,

FORM display_data .

   READ TABLE it_main INTO wa_main WITH KEY mark = 'X'.

   IF mark IS NOT INITIAL.

     LOOP AT it_zexp_advice INTO wa_zexp_advice WHERE eorder = wa_main-eorder.

       wa_zexp_advice-mark = 'X'.

       MODIFY it_zexp_advice FROM wa_zexp_advice.

     ENDLOOP.

   ENDIF.

   DELETE it_zexp_advice WHERE mark NE 'X'.

   DESCRIBE TABLE it_zexp_advice LINES lv_lines.

   READ TABLE it_zexp_advice INTO wa_zexp_advice INDEX lv_lines.

   IF sy-subrc = 0.

     lv_posnr = wa_zexp_advice-sr_no.

   ENDIF.

   READ TABLE it_zexp_advice INTO wa_zexp_advice WITH KEY eorder = wa_main-eorder.

   wa_zexp_advice-sr_no = wa_zexp_advice-sr_no + 1.

   lwa_expadvice-sr_no = lv_posnr + '1'.

   lwa_expadvice-eorder = wa_zexp_advice-eorder.

   lwa_expadvice-buyer = wa_zexp_advice-buyer.

   lwa_expadvice-buyer_code = wa_zexp_advice-buyer_code.

   lwa_expadvice-containers = wa_zexp_advice-containers.

   lwa_expadvice-dispatch_sch = wa_zexp_advice-dispatch_sch.

   lwa_expadvice-last_date_dispatch = wa_zexp_advice-last_date_dispatch.

   lwa_expadvice-zcpyear              = wa_zexp_advice-zcpyear.

   lwa_expadvice-basic_artwork = wa_zexp_advice-basic_artwork.

   lwa_expadvice-ty_pack_mat = wa_zexp_advice-ty_pack_mat.

   lwa_expadvice-zzip        = wa_zexp_advice-zzip.

   lwa_expadvice-zcatagory   = wa_zexp_advice-zcatagory.

   lwa_expadvice-packing_date_bags = wa_zexp_advice-packing_date_bags.

   lwa_expadvice-best_bfr_bags = wa_zexp_advice-best_bfr_bags.

   lwa_expadvice-crop_year_bags = wa_zexp_advice-crop_year_bags.

   lwa_expadvice-ztype          = wa_zexp_advice-ztype.

   lwa_expadvice-batch_bags = wa_zexp_advice-batch_bags.

   lwa_expadvice-zgmpno     = wa_zexp_advice-zgmpno.

   lwa_expadvice-barcode_bags = wa_zexp_advice-barcode_bags.

   lwa_expadvice-zholo_bags   = wa_zexp_advice-zholo_bags.

   lwa_expadvice-zlogo_bags   = wa_zexp_advice-zlogo_bags.

   lwa_expadvice-zplas_bags   = wa_zexp_advice-zplas_bags.

   lwa_expadvice-zgift_bags   = wa_zexp_advice-zgift_bags.

   lwa_expadvice-zlott_bags   = wa_zexp_advice-zlott_bags.

   lwa_expadvice-zcolor_bags  = wa_zexp_advice-zcolor_bags.

   lwa_expadvice-zpackcat     = wa_zexp_advice-zpackcat.

   lwa_expadvice-tag_bags     = wa_zexp_advice-tag_bags.

   lwa_expadvice-stitching    = wa_zexp_advice-stitching.

   lwa_expadvice-stickers     = wa_zexp_advice-stickers.

   lwa_expadvice-fumigation   = wa_zexp_advice-fumigation.

   lwa_expadvice-inner_bag = wa_zexp_advice-inner_bag.

   lwa_expadvice-seal = wa_zexp_advice-seal.

   lwa_expadvice-empty_bags = wa_zexp_advice-empty_bags.

   lwa_expadvice-sample_pre_shipment = wa_zexp_advice-sample_pre_shipment.

   lwa_expadvice-sample_post_shipment = wa_zexp_advice-sample_post_shipment.

   lwa_expadvice-sample_oaa = wa_zexp_advice-sample_oaa.

   lwa_expadvice-third_party_ins = wa_zexp_advice-third_party_ins.

   lwa_expadvice-blank1 = wa_zexp_advice-blank1.

   lwa_expadvice-blank2 = wa_zexp_advice-blank2.

   lwa_expadvice-blank3 = wa_zexp_advice-blank3.

   lwa_expadvice-blank4 = wa_zexp_advice-blank4.

   lwa_expadvice-blank5 = wa_zexp_advice-blank5.

   lwa_expadvice-prepared_by = wa_zexp_advice-prepared_by.

   lwa_expadvice-prepared_date = wa_zexp_advice-prepared_date.

   lwa_expadvice-approved_by = wa_zexp_advice-approved_by.

   lwa_expadvice-approved_date = wa_zexp_advice-approved_date.

   lwa_expadvice-ppc = wa_zexp_advice-ppc.

   lwa_expadvice-eano = wa_zexp_advice-eano.

   lwa_expadvice-others_txt = wa_zexp_advice-others_txt.

   lwa_expadvice-other_name = wa_zexp_advice-other_name.

   lwa_expadvice-zprirority = wa_main1-zprirority.

   lwa_expadvice-zplant     = wa_main1-zplant.

   lwa_expadvice-zdate = wa_main1-zdate.

   lwa_expadvice-ztime = sy-uzeit.

   MODIFY zexp_advice FROM lwa_expadvice.

   APPEND lwa_expadvice TO lt_expadvice.

   DESCRIBE TABLE lt_expadvice LINES tc_it_main2-lines.

   IF lt_expadvice IS NOT INITIAL.

     INSERT zexp_advice FROM TABLE lt_expadvice ACCEPTING DUPLICATE KEYS.

   ENDIF.

   CLEAR: lv_posnr.

   LOOP AT it_zea_packaging INTO wa_zea_packaging WHERE eorder = wa_main-eorder.

     wa_zea_packaging-mark = 'X'.

     MODIFY it_zea_packaging FROM wa_zea_packaging.

   ENDLOOP.

   DELETE it_zea_packaging WHERE mark NE 'X'.

   DESCRIBE TABLE it_zea_packaging LINES lv_lines1.

   READ TABLE it_zea_packaging INTO wa_zea_packaging INDEX lv_lines1.

   IF sy-subrc = 0.

     lv_posnr1 = wa_zea_packaging-sr_no.

     lv_posnr = wa_zea_packaging-posnr.

   ENDIF.

   READ TABLE it_zea_packaging INTO wa_zea_packaging WITH KEY eorder = wa_zexp_advice-eorder.

   lwa_eapackaging-eorder = wa_zea_packaging-eorder.

   lwa_eapackaging-posnr = lv_posnr + '0010'.

   lwa_eapackaging-sr_no = lv_posnr1 + '1'.

   lwa_eapackaging-ztime = sy-uzeit.

   lwa_eapackaging-matnr = wa_zea_packaging-matnr.

   lwa_eapackaging-product = wa_zea_packaging-product.

   lwa_eapackaging-packing_size = wa_zea_packaging-packing_size.

   lwa_eapackaging-no_of_packs = wa_zea_packaging-no_of_packs.

   lwa_eapackaging-tonnage = wa_zea_packaging-tonnage.

   lwa_eapackaging-no_of_cartons = wa_zea_packaging-no_of_cartons.

   lwa_eapackaging-product_mix = wa_zea_packaging-product_mix.

   lwa_eapackaging-purity = wa_zea_packaging-purity.

   lwa_eapackaging-moisture = wa_zea_packaging-moisture.

   lwa_eapackaging-broken_3_4th = wa_zea_packaging-broken_3_4th.

   lwa_eapackaging-admixture = wa_zea_packaging-admixture.

   lwa_eapackaging-damage = wa_zea_packaging-damage.

   lwa_eapackaging-discolor = wa_zea_packaging-discolor.

   lwa_eapackaging-immature = wa_zea_packaging-immature.

   lwa_eapackaging-abnormal = wa_zea_packaging-abnormal.

   lwa_eapackaging-chalky = wa_zea_packaging-chalky.

   lwa_eapackaging-foreign_matter = wa_zea_packaging-foreign_matter.

   lwa_eapackaging-avg_length = wa_zea_packaging-avg_length.

   lwa_eapackaging-insects = wa_zea_packaging-insects.

   lwa_eapackaging-paddy_grains = wa_zea_packaging-paddy_grains.

   lwa_eapackaging-yellow_grains = wa_zea_packaging-yellow_grains.

   lwa_eapackaging-whiteness = wa_zea_packaging-whiteness.

   lwa_eapackaging-white_belly = wa_zea_packaging-white_belly.

   lwa_eapackaging-texture = wa_zea_packaging-texture.

   lwa_eapackaging-green_grains = wa_zea_packaging-green_grains.

   lwa_eapackaging-crop_year = wa_zea_packaging-crop_year.

   lwa_eapackaging-aroma = wa_zea_packaging-aroma.

   lwa_eapackaging-pin_broken = wa_zea_packaging-pin_broken.

   lwa_eapackaging-l_b_ratio = wa_zea_packaging-l_b_ratio.

   lwa_eapackaging-avg_thickness = wa_zea_packaging-avg_thickness.

   lwa_eapackaging-avg_breadth = wa_zea_packaging-avg_breadth.

   lwa_eapackaging-red_grains = wa_zea_packaging-red_grains.

   lwa_eapackaging-others1 = wa_zea_packaging-others1.

   lwa_eapackaging-others2 = wa_zea_packaging-others2.

   lwa_eapackaging-others3 = wa_zea_packaging-others3.

   lwa_eapackaging-others4 = wa_zea_packaging-others4.

   lwa_eapackaging-others5 = wa_zea_packaging-others5.

   lwa_eapackaging-zodour = wa_zea_packaging-zodour.

   lwa_eapackaging-zamber = wa_zea_packaging-zamber.

   lwa_eapackaging-zprocess_qty = wa_main1-zprocess_qty.

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

  balance = lwa_eapackaging-tonnage - ( wa_main1-zprocess_qty + wa_main-zprocess_qty ) .

   lwa_eapackaging-zbal_qty = balance.

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

   LOOP AT it_zea_packaging INTO wa_zea_packaging.

   IF sy-tabix <> 1.

     it_zea_packaging-tonnage = balance.

     MODIFY it_zea_packaging TRANSPORTING tonnage.

   ENDIF.

     balance = it_zea_packaging-tonnage - it_zea_packaging-zprocess_qty.

   ENDLOOP.

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

   MODIFY zea_packaging FROM lwa_eapackaging.

   APPEND lwa_eapackaging TO lt_eapackaging.

   IF lt_eapackaging IS NOT INITIAL.

     INSERT zea_packaging FROM TABLE lt_eapackaging ACCEPTING DUPLICATE KEYS.

   ENDIF.

*  DESCRIBE TABLE lt_eapackaging LINES tc_it_main2-lines.

   IF wa_main1-zprocess_qty GT wa_main-tonnage.

     MESSAGE 'Quantity to be processed is greater than total Quantity' TYPE 'I' DISPLAY LIKE 'E'.

     CALL SCREEN 9010.

   ENDIF.

*           REFRESH CONTROL 'tc_it_main2' FROM SCREEN 9011.

*      IF sy-subrc = 0.

*        COMMIT WORK.

*        MESSAGE 'Record updated sucessfully' TYPE 'S'.

*      ELSE.

*      ENDIF.

   REFRESH CONTROL 'tc_it_main2' FROM SCREEN 9011.

   SELECT * FROM zexp_advice

   INTO CORRESPONDING FIELDS OF TABLE it_zexp_advice1

   FOR ALL ENTRIES IN it_zexp_advice

   WHERE eorder = it_zexp_advice-eorder.

   SELECT * FROM zea_packaging

   INTO CORRESPONDING FIELDS OF TABLE it_zea_packaging1

   FOR ALL ENTRIES IN it_zexp_advice1

   WHERE eorder = it_zexp_advice1-eorder

         AND sr_no = it_zexp_advice1-sr_no.

   DATA : lv_last_bal TYPE zea_packaging-zbal_qty.

   LOOP AT it_main INTO wa_main WHERE mark = 'X'.

     LOOP AT it_zexp_advice1 INTO wa_zexp_advice1 WHERE eorder = wa_main-eorder.

       wa_main2-eorder        = wa_zexp_advice1-eorder.

       wa_main2-eano          = wa_zexp_advice1-eano.

       wa_main2-buyer         = wa_zexp_advice1-buyer.

       wa_main2-buyer_code    = wa_zexp_advice1-buyer_code.

       wa_main2-zprirority    = wa_zexp_advice1-zprirority.

       wa_main2-zplant        = wa_zexp_advice1-zplant.

       wa_main2-zdate          = wa_zexp_advice1-zdate.

       READ TABLE it_vbap INTO wa_vbap WITH KEY vbeln = wa_main-eorder .

       wa_main2-matnr         = wa_vbap-matnr.

       wa_main2-arktx         = wa_vbap-arktx.

       wa_main2-mark          = wa_vbap-mark.

       READ TABLE it_zea_packaging1 INTO wa_zea_packaging1 WITH KEY eorder = wa_zexp_advice1-eorder

                                                                    sr_no  = wa_zexp_advice1-sr_no.

       wa_main2-tonnage      = wa_zea_packaging1-tonnage.

       wa_main2-zprocess_qty = wa_zea_packaging1-zprocess_qty.

       wa_main2-zbal_qty     = wa_zea_packaging1-zbal_qty.

       APPEND wa_main2 TO it_main2.

       DELETE it_main2 WHERE zplant = ' '.

       CLEAR : wa_vbap ,wa_zexp_advice1, wa_zea_packaging1, wa_main2.

     ENDLOOP.

   ENDLOOP.

ENDFORM.                    " DISPLAY_DATA


Kindly suggest.


Thanks and Regards

Jai

Read only

0 Likes
5,963

Hi Jai,

I am a bit confused  why you have so many lines of code.

Could you please put a screenshot of the internal table data it_zea_packaging in debugging?

Thanks,

Naveen

Read only

0 Likes
5,963

Dear Naveen,

 

Actually i have moved the data of it_zea_packaging into it_zea_packaging1. and debug mode of both of them is there in screen shot.

Thanks and Regards

Jai

Read only

0 Likes
5,963

Second time when i have added the record, its deducting the value from initial value.

Regards

Jai

Read only

0 Likes
5,963

There is something wrong with the calculation logic.

You will have to do a rework on the code I guess.

What I would suggest is for everytime the user enters data in first screen just append it to a new table. Then you can use a similar logic like below for calculating in code and displaying it in table control.

Loop at ITAB.

if sy-tabix <> 1.

itab-total = lv_balance.

modify itab transporting total.

endif.

lv_balance = itab-total - itab-qtytobeprocessed

Endloop.

and you can have a variable or something that keeps track of the qty left out. It is too hard to explain in detail. we can just provide you some useful information with which you will have to improvise and achieve the requirement.

Thanks,

Naveen

Read only

former_member202818
Active Contributor
0 Likes
5,963

HI Jai,

Why do you want a different screen for adding records in table control? Table control itself is editable.

Table control only shows the records fom the internal table attached with it. 

Regards

Sreekanth

Read only

0 Likes
5,963

Dear Sreekanth,

I am updating my z-table with the record that is there in table control.

Thanks and Regards

Jai

Read only

0 Likes
5,963

Dear Naveen,

I have resolved that issue. Thank you for your support. I am having again a issue in the same code. Suppose i am deleting the record from table control, its deleting the record from the internal table. but i need to delete that set of record from database table as well. that is not working.

Kindly suggest.

Regards

Jai

Read only

0 Likes
5,963

Hi Jai,

What you will have to do is when you delete the data from your internal table, jsut before you delete have that record in a separate work area and use a statement to delete the data from database as well. For eg you have a work area which has the values that you have deleted from internal table, just use that work area and move to a structure similar to database then use a delete like below:

DELETE <database table> from <work area>.

Thanks,

Naveen

Read only

0 Likes
5,963

Dear Naveen,

I have tried in the same way, But its not working.

WHEN 'DELE'.

       MESSAGE 'This will delete entire row,still you want to continue' TYPE 'W'.

       READ TABLE it_main2 INTO wa_main2 WITH KEY mark = 'X'.

       READ TABLE it_zexp_advice1 INTO wa_zexp_advice1 WITH KEY eorder = wa_main2-eorder

                                                                         mark = 'X'.

       DELETE it_main2 WHERE mark = 'X'.

       DESCRIBE TABLE it_main2 LINES tc_it_main2-lines.

         MOVE-CORRESPONDING wa_main2 TO  wa_vbap1.

         MOVE-CORRESPONDING wa_main2 TO wa_zexp_advice2.

         MOVE-CORRESPONDING wa_main2 TO wa_zea_packaging2.

   BREAK ABAP_BFL.

         DELETE vbap FROM wa_vbap1.

         DELETE zexp_advice FROM wa_zexp_advice2.

         DELETE zea_packaging FROM wa_zea_packaging2.


Thanks and Regards

Jai

Read only

0 Likes
5,963

Hi Jai,

What is the Break ABAP_BFL do?

You can try the below whichever works:

First check in debugging if the code for delete is getting executed.

if it is reaching the code then Try to do the delete process and use this break statement after delete.

if above doesn't work then try to put a COMMIT WORK after delete.

Also check if you have any entries in the work area in debugging while you reach the delete statement.

Check sy-subrc after the delete statement.

Do these and let me know.

Thanks,

Naveen