08-21-2007 11:23 PM
Hi,
I am uploading the data from excel to a custom table. I have Display data to display contents of the table from a report. How can I check the check boxes of the newly uploaded records using user command 'SELE'.
Thank you.
Neelu.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
IF chbox = 'X'.
chbox = ' '.
ELSEIF chbox = ' '.
chbox = 'X'.
ENDIF.
PERFORM displaydata.
FORM displaydata.
SET PF-STATUS 'LIST'.
NEW-PAGE LINE-SIZE 253.
SELECT * FROM zppprice
INTO TABLE gt_zprice.
WRITE: /01(253) sy-uline.
LOOP AT gt_zprice INTO gs_zprice.
SELECT SINGLE name1 FROM kna1 INTO kna1-name1
WHERE kunnr = gs_zprice-kunnr.
WRITE: /01 sy-vline,
02 chbox AS CHECKBOX,
04 sy-vline,
05 gs_zprice-vkorg,
10 sy-vline,
11 gs_zprice-vtweg,
14 sy-vline,
15 gs_zprice-spart,
18 sy-vline,
19 gs_zprice-kunnr,
30 sy-vline,
31 kna1-name1,
67 sy-vline,
68 gs_zprice-matnr,
87 sy-vline,
88 gs_zprice-crdate,
98 sy-vline,
99 gs_zprice-efdate,
110 sy-vline,
111 gs_zprice-sprice,
127 sy-vline,
128 gs_zprice-eprice,
145 sy-vline,
146 gs_zprice-eohqty,
157 sy-vline,
158 gs_zprice-aohqty,
169 sy-vline,
170 gs_zprice-auart,
175 sy-vline,
176 gs_zprice-bstkd,
212 sy-vline,
213 gs_zprice-werks,
218 sy-vline,
219 gs_zprice-augru,
223 sy-vline,
224 gs_zprice-xblnr,
241 sy-vline,
242 gs_zprice-crmemo,
253 sy-vline.
ENDLOOP.
WRITE: /01(253) sy-uline.
CLEAR gt_zprice.
ENDFORM.
08-22-2007 12:00 AM
I guess you have date field or time field or some flag field in table.
if so you can use some logic to get functionality..
if that then use check box = 'X',then this will become newly upload records..
Thanks
Seshu
08-22-2007 12:00 AM
I guess you have date field or time field or some flag field in table.
if so you can use some logic to get functionality..
if that then use check box = 'X',then this will become newly upload records..
Thanks
Seshu
08-22-2007 12:56 AM
Hi Sheshu,
I have Creation Date - CRDATE in the table, but I do not have selection screen. How can I check on most recent CRDATE value.
Thank you.
Regards,
Neelu.
08-22-2007 2:10 AM
Can you please explian about functionality ?
My assumption is - You have selection-screen ,here you are uploading the data from xl file to internal table ,from internal table to custom table,you use simple modify command to update into custom table.
here you can keep one flag varaibale in internal table,use that flag variable to display the data in report format.
Still i am confusion about req..
Thanks
Seshu
08-22-2007 5:29 PM
Hi Seshu,
I have one custom table and 3 programs for this req.
First I will upload data from excel file using selection-screen for file name, here I am uploading the data from excel file to internal table ,from internal table to custom table, I used modify command to update into custom table.
Second one is the module pool to Display, Create and Change contents of the Custom Table.
Third Report was called from Display table. This display table displays the contents of the table and here each record will have check box to create the Credit Memo. The credit memos will be created for all checked records by pressing the 'create cm' button. I want another button here to check all the records with the most recent date on it.
Please let me know if the req is clear and please help me to add this button to select the records with most recent crdate.
Thanks,
Neelu.
08-22-2007 6:10 PM
Hi Neelu,
the only way you can write logic ,creation date...
keep sy-datum with compare table creation date..,
i mean you can write simple logic..
declare one range
ranges r_date for sy-datum.
fill the values to range
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
append r_date.
select * from table into table int_table
where credate in r_date. " Assume that you are getting 1 week data.
Talk to your functional guy ,other than this we will not have any control unless if we have any other condition with respective table
Thanks
Seshu
08-22-2007 7:05 PM
Hi Seshu,
Now I am getting the records in the itab with in the range. But how can I make the check box = 'X' for these records. Here index is comming as '0'.
Thank you.
Neelu.
TYPES: BEGIN OF ty_zprice,
mandt TYPE mandt,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
spart TYPE spart,
kunnr TYPE kunnr,
matnr TYPE matnr,
crdate TYPE zcrdate,
efdate TYPE zefdate,
sprice TYPE zprice3,
eprice TYPE zprice4,
eohqty TYPE zquantity1,
aohqty TYPE zquantity2,
auart TYPE auart,
bstkd TYPE bstkd,
werks TYPE werks_d,
augru TYPE augru,
xblnr TYPE xblnr,
crmemo TYPE vbeln,
index TYPE sy-index,
END OF ty_zprice.
gt5_zprice TYPE TABLE OF ty_zprice WITH HEADER LINE,
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
IF chbox = 'X'.
chbox = ' '.
ELSEIF chbox = ' '.
chbox = 'X'.
ENDIF.
PERFORM displaydata.
FORM displaydata.
SET PF-STATUS 'LIST'.
NEW-PAGE LINE-SIZE 253.
SELECT * FROM zppprice
INTO TABLE gt_zprice.
WRITE: /01(253) sy-uline.
LOOP AT gt_zprice INTO gs_zprice.
SELECT SINGLE name1 FROM kna1 INTO kna1-name1
WHERE kunnr = gs_zprice-kunnr.
WRITE: /01 sy-vline,
02 chbox AS CHECKBOX,
04 sy-vline,
05 gs_zprice-vkorg,
10 sy-vline,
11 gs_zprice-vtweg,
14 sy-vline,
15 gs_zprice-spart,
18 sy-vline,
19 gs_zprice-kunnr,
30 sy-vline,
31 kna1-name1,
67 sy-vline,
68 gs_zprice-matnr,
87 sy-vline,
88 gs_zprice-crdate,
98 sy-vline,
99 gs_zprice-efdate,
110 sy-vline,
111 gs_zprice-sprice,
127 sy-vline,
128 gs_zprice-eprice,
145 sy-vline,
146 gs_zprice-eohqty,
157 sy-vline,
158 gs_zprice-aohqty,
169 sy-vline,
170 gs_zprice-auart,
175 sy-vline,
176 gs_zprice-bstkd,
212 sy-vline,
213 gs_zprice-werks,
218 sy-vline,
219 gs_zprice-augru,
223 sy-vline,
224 gs_zprice-xblnr,
241 sy-vline,
242 gs_zprice-crmemo,
253 sy-vline.
ENDLOOP.
WRITE: /01(253) sy-uline.
CLEAR gt_zprice.
ENDFORM. " Displaydata
08-22-2007 7:56 PM
Hi seshu,
I tried this. It is not working but any suggestions related to this.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
DESCRIBE TABLE gt_zprice LINES lv_cnt.
DO lv_cnt TIMES.
lv_index = sy-index + 1.
READ LINE lv_index FIELD VALUE gt_zprice-crdate.
IF gt_zprice-crdate in r_date.
chbox = 'X'.
ENDIF.
ENDDO.
PERFORM displaydata.
Thank you.
Neelima.
08-22-2007 8:11 PM
If you set "chbox" to 'X', the checkbox should come as checked when you write. The following simple program illustrates that.
DATA v_checkbox VALUE 'X'.
DO 10 TIMES.
WRITE:/ v_checkbox AS CHECKBOX.
ENDDO.
08-22-2007 9:18 PM
Hi Neelu,
Sorry for late reply..
You can keep one internal table,this internal table will contain total custom table fields as well check box field.
so keep check box field as 'X' what ever date condition in your select query.
select * from table into table int_table..
where date in R_date.
Note : should not use range in if condition.
loop at int_table.
chk_box = 'X'.
modify table int_table.
endloop.
now use int_table to display all the data with check box.
Hope you got it.
Thanks
Seshu
08-22-2007 9:58 PM
Hi Seshu,
Now the internal table has the records with in the date range and check box is checked.
Is there any way we can have all the records in the internal table including checked records also. User wants to see all data.
Can I update or modify the internal table gt_zprice(all records) with gt5_zprice(checked records). So that I can display data based on gt_zprice(all records).
Thank you Seshu.
Regards,
Neelu.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
LOOP AT gt5_zprice.
chbox = 'X'.
MODIFY TABLE gt5_zprice.
ENDLOOP.
Thank you Seshu.
Regards,
Neelu.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
LOOP AT gt5_zprice.
chbox = 'X'.
MODIFY TABLE gt5_zprice.
ENDLOOP.
08-22-2007 10:13 PM
Hi Neelu,
You can select the data from database table,there should be status whether record is processed or not
LOOP AT gt5_zprice.
I guess you need include logic here
if table-field = 'X' . processed
chbox = ''.
else.
chbox = 'X'.
endif.
MODIFY TABLE gt5_zprice.
ENDLOOP.
Thanks
Seshu
08-22-2007 11:06 PM
Hi Seshu,
Sorry for the confusion.
Now the internal table has the records with in the date range and check box is checked.
I gave 2 records in the date range and I got those 2 records in gt5_zprice.
Is there any way we can have all the records in the internal table including checked records also. User wants to see all records checked and unchecked in the display.
Can I update or modify the main internal table gt_zprice(all records) with gt5_zprice(checked records). So that I can display data based on gt_zprice(all records).
Thank you Seshu.
Regards,
Neelu.
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
LOOP AT gt5_zprice.
chbox = 'X'.
MODIFY TABLE gt5_zprice.
ENDLOOP.
PERFORM displaydata.
08-23-2007 12:04 AM
You have answer Neelu... Just do compare with main internal table with current internal table,update the data into current internal table.
do not use main internal table ,you may get confused,so use gt5_zprice for displaying the data..
Thanks
Seshu
08-23-2007 12:54 AM
08-23-2007 1:00 AM
Hi,
As per Seshu, he need to use gt5_zprice instead of gt_zprice in the form DISPLAYDATA.
aRs
08-23-2007 3:22 AM
Hello Neelu,
Once you done check box logic with gt5_price then just use
append lines of gt_price to gt5_price. " check the syntax of Append lines
Once you done this..
now you will have checked and unchecked data ..
Thanks
Seshu
08-23-2007 5:53 PM
Hi Seshu,
I tried it, it is either checking all check boxes or un check all after the Append.
Before gt5_zprice has 2 records checked. And Append stmt is adding the 2 records in date range twice. I have total 18 records and 2 of them are in the date range. after Append it is adding 2 records again and total of 20.
Please helpme to solve this.
Thanks,
Neelu.
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
LOOP AT gt5_zprice.
chbox = 'X'.
MODIFY TABLE gt5_zprice.
ENDLOOP.
LOOP AT gt_zprice.
chbox = ' '.
MODIFY TABLE gt_zprice.
ENDLOOP.
APPEND LINES OF gt_zprice TO gt5_zprice.
SET PF-STATUS 'LIST'.
NEW-PAGE LINE-SIZE 253.
WRITE: /01(253) sy-uline.
LOOP AT gt5_zprice INTO gs_zprice.
WRITE: /01 sy-vline,
02 chbox AS CHECKBOX,
04 sy-vline,
05 gs_zprice-vkorg,
10 sy-vline,
11 gs_zprice-vtweg,
14 sy-vline,
15 gs_zprice-spart,
18 sy-vline,
19 gs_zprice-kunnr,
30 sy-vline,
31 kna1-name1,
67 sy-vline,
68 gs_zprice-matnr,
87 sy-vline,
88 gs_zprice-crdate,
98 sy-vline,
99 gs_zprice-efdate,
110 sy-vline,
111 gs_zprice-sprice,
127 sy-vline,
128 gs_zprice-eprice,
145 sy-vline,
146 gs_zprice-eohqty,
157 sy-vline,
158 gs_zprice-aohqty,
169 sy-vline,
170 gs_zprice-auart,
175 sy-vline,
176 gs_zprice-bstkd,
212 sy-vline,
213 gs_zprice-werks,
218 sy-vline,
219 gs_zprice-augru,
223 sy-vline,
224 gs_zprice-xblnr,
241 sy-vline,
242 gs_zprice-crmemo,
253 sy-vline.
ENDLOOP.
WRITE: /01(253) sy-uline.
08-23-2007 7:53 PM
Check the sample program :
REPORT ZJOINS .
data : begin of itab occurs 0,
chkbox(1) type c,
fld1(3) type c,
fld2 type i,
end of itab.
data : begin of itab1 occurs 0,
chkbox(1) type c,
fld1(3) type c,
fld2 type i,
end of itab1.
start-of-selection.
Itab
itab-chkbox = 'X'.
itab-fld1 = 'ABC'.
itab-fld2 = 100.
append itab.
itab-chkbox = 'X'.
itab-fld1 = 'ABC'.
itab-fld2 = 100.
append itab.
Itab1
itab1-fld1 = 'ABC'.
itab1-fld2 = 100.
append itab1.
itab1-chkbox = 'X'.
itab1-fld1 = 'ABC'.
itab1-fld2 = 100.
append itab1.
APPEND LINES OF ITAB1 to itab.
loop at itab.
WRITE: /01 itab-chkbox AS CHECKBOX,
10 itab-fld1,
20 itab-fld2.
endloop.
I found something at your program :
LOOP AT gt5_zprice INTO gs_zprice.
WRITE: /01 sy-vline,
<b> 02 chbox AS CHECKBOX, -> here you are getting issue ,this should be gs_zprice-chbox</b>
Thanks
Seshu
08-23-2007 9:38 PM
Hi Seshu,
Sorry it is taking too much of your time.
I donot have check box field in ty_zprice. Should I add it here. Please look at the report.
Thanks,
Neelu.
REPORT zsd_creditmemo NO STANDARD PAGE HEADING.
TABLES: zppprice, kna1.
TYPES: BEGIN OF ty_zprice,
mandt TYPE mandt,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
spart TYPE spart,
kunnr TYPE kunnr,
matnr TYPE matnr,
crdate TYPE zcrdate,
efdate TYPE zefdate,
sprice TYPE zprice3,
eprice TYPE zprice4,
eohqty TYPE zquantity1,
aohqty TYPE zquantity2,
auart TYPE auart,
bstkd TYPE bstkd,
werks TYPE werks_d,
augru TYPE augru,
xblnr TYPE xblnr,
crmemo TYPE vbeln,
index TYPE sy-index,
END OF ty_zprice.
DATA: gt_zprice TYPE TABLE OF zppprice WITH HEADER LINE,
gt1_zprice TYPE TABLE OF zppprice,
gt2_zprice TYPE TABLE OF ty_zprice WITH HEADER LINE,
gt3_zprice TYPE TABLE OF ty_zprice,
gt4_zprice TYPE TABLE OF ty_zprice WITH HEADER LINE,
gt5_zprice TYPE TABLE OF ty_zprice WITH HEADER LINE,
gs_zprice TYPE zppprice,
gs_zprice1 TYPE ty_zprice,
ls_zprice TYPE ty_zprice,
wa LIKE zppprice.
DATA: salesdocument TYPE bapivbeln-vbeln.
DATA: header LIKE bapisdhd1.
DATA: headerx LIKE bapisdhd1x.
DATA: item LIKE bapisditm OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditmx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapiparnr OCCURS 0 WITH HEADER LINE.
DATA: return1 LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: conditions1 LIKE bapicond OCCURS 0 WITH HEADER LINE.
DATA: order_text LIKE bapisdtext OCCURS 0 WITH HEADER LINE.
DATA: lv_index TYPE sy-index,
v_tabix TYPE sytabix,
chbox(1) TYPE c VALUE ' ',
repid TYPE sy-repid,
lv_itemno TYPE i VALUE 10,
lv_pprice TYPE zprice3,
lv_lines TYPE i,
lv_flg TYPE c,
lv_cnt TYPE i.
RANGES r_date FOR sy-datum.
repid = sy-repid.
PERFORM displaydata.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELE'.
* SET PF-STATUS 'STAT'.
* IF chbox = 'X'.
* chbox = ' '.
* ELSEIF chbox = ' '.
* chbox = 'X'.
* ENDIF.
* PERFORM displaydata.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
LOOP AT gt5_zprice.
chbox = 'X'.
MODIFY TABLE gt5_zprice.
ENDLOOP.
LOOP AT gt_zprice.
chbox = ' '.
MODIFY TABLE gt_zprice.
ENDLOOP.
APPEND LINES OF gt_zprice TO gt5_zprice.
SET PF-STATUS 'LIST'.
NEW-PAGE LINE-SIZE 253.
WRITE: /01(253) sy-uline.
LOOP AT gt5_zprice INTO gs_zprice.
WRITE: /01 sy-vline,
02 chbox,
04 sy-vline,
05 gs_zprice-vkorg,
10 sy-vline,
11 gs_zprice-vtweg,
14 sy-vline,
15 gs_zprice-spart,
18 sy-vline,
19 gs_zprice-kunnr,
30 sy-vline,
31 kna1-name1,
67 sy-vline,
68 gs_zprice-matnr,
87 sy-vline,
88 gs_zprice-crdate,
98 sy-vline,
99 gs_zprice-efdate,
110 sy-vline,
111 gs_zprice-sprice,
127 sy-vline,
128 gs_zprice-eprice,
145 sy-vline,
146 gs_zprice-eohqty,
157 sy-vline,
158 gs_zprice-aohqty,
169 sy-vline,
170 gs_zprice-auart,
175 sy-vline,
176 gs_zprice-bstkd,
212 sy-vline,
213 gs_zprice-werks,
218 sy-vline,
219 gs_zprice-augru,
223 sy-vline,
224 gs_zprice-xblnr,
241 sy-vline,
242 gs_zprice-crmemo,
253 sy-vline.
ENDLOOP.
WRITE: /01(253) sy-uline.
* PERFORM displaydata.
WHEN 'CMEMO'.
DESCRIBE TABLE gt_zprice LINES lv_cnt.
DO lv_cnt TIMES.
lv_index = sy-index + 1.
READ LINE lv_index FIELD VALUE chbox.
IF chbox = 'X'.
READ TABLE gt_zprice INTO gs_zprice1 INDEX sy-index.
IF sy-subrc EQ 0.
gs_zprice1-index = sy-index.
APPEND gs_zprice1 TO gt2_zprice.
CLEAR gs_zprice1.
ENDIF.
ENDIF.
CLEAR chbox.
ENDDO.
gt4_zprice[] = gt2_zprice[].
LOOP AT gt4_zprice INTO gs_zprice1.
IF gs_zprice1-crmemo IS INITIAL.
AT NEW kunnr.
MOVE 'Y' TO lv_flg.
ENDAT.
IF lv_flg EQ 'Y'.
PERFORM headerdata.
PERFORM texts.
CLEAR lv_flg.
ENDIF.
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
CLEAR gs_zprice1.
AT END OF kunnr.
PERFORM call_function.
PERFORM update_pricetable.
PERFORM errorcheckandcommit.
REFRESH gt2_zprice.
CLEAR chbox.
CLEAR lv_lines.
REFRESH partner.
REFRESH item.
REFRESH itemx.
REFRESH lt_schedules_in.
REFRESH lt_schedules_inx.
REFRESH conditions1.
REFRESH order_text.
lv_itemno = 10.
ENDAT.
ELSE.
REFRESH gt2_zprice.
CLEAR chbox.
ENDIF.
ENDLOOP.
PERFORM displaydata.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form headerdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM headerdata.
* header data
* Sales document type
header-doc_type = gs_zprice1-auart.
headerx-doc_type = 'X'.
* Sales organization
header-sales_org = gs_zprice1-vkorg.
headerx-sales_org = 'X'.
* Distribution channel
header-distr_chan = gs_zprice1-vtweg.
headerx-distr_chan = 'X'.
* Division
header-division = gs_zprice1-spart.
headerx-division = 'X'.
* Customer PO Number
header-purch_no_c = gs_zprice1-bstkd.
headerx-purch_no_c = 'X'.
* Order Reason
header-ord_reason = gs_zprice1-augru.
headerx-ord_reason = 'X'.
* Ref Doc Number
header-ref_doc_l = gs_zprice1-xblnr.
headerx-ref_doc_l = 'X'.
headerx-updateflag = 'I'.
ENDFORM. " headerdata
*&---------------------------------------------------------------------*
*& Form Texts
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM texts.
*Texts
order_text-itm_number = '000000'.
order_text-text_id = '0001'.
order_text-langu = sy-langu.
order_text-text_line = gs_zprice1-xblnr.
APPEND order_text.
ENDFORM. " Texts
*&---------------------------------------------------------------------*
*& Form itemdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM itemdata.
* Partner data
* Sold to
partner-partn_role = 'AG'.
partner-partn_numb = gs_zprice1-kunnr.
APPEND partner.
* ITEM DATA
itemx-updateflag = 'I'.
* Line item number.
item-itm_number = lv_itemno.
itemx-itm_number = 'X'.
* Material
item-material = gs_zprice1-matnr.
itemx-material = 'X'.
* Plant
item-plant = gs_zprice1-werks.
itemx-plant = 'X'.
* Quantity
item-target_qty = gs_zprice1-eohqty.
itemx-target_qty = 'X'.
APPEND item.
APPEND itemx.
*Fill schedule lines
lt_schedules_in-itm_number = lv_itemno.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = gs_zprice1-eohqty.
APPEND lt_schedules_in.
*Fill schedule line flags
lt_schedules_inx-itm_number = lv_itemno.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'I'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
*Conditions
lv_pprice = gs_zprice1-sprice - gs_zprice1-eprice.
conditions1-itm_number = lv_itemno.
conditions1-cond_type = 'ZCPP'.
conditions1-cond_value = lv_pprice.
conditions1-currency = 'USD'.
conditions1-cond_unit = 'EA'.
conditions1-cond_p_unt = 1.
APPEND conditions1.
lv_itemno = lv_itemno + 10.
ENDFORM. " itemdata
*&---------------------------------------------------------------------*
*& Form call_function
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM call_function.
CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = salesdocument
TABLES
return = return1
sales_items_in = item
sales_items_inx = itemx
sales_partners = partner
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_conditions_in = conditions1
sales_text = order_text.
ENDFORM. " call_function
*&---------------------------------------------------------------------*
*& Form errorcheck
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM errorcheckandcommit.
* Check the return table.
LOOP AT return1 WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
*Commit the work.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDFORM. " errorcheckandcommit
*&---------------------------------------------------------------------*
*& Form update_pricetable
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM update_pricetable.
LOOP AT gt3_zprice INTO ls_zprice.
READ TABLE gt_zprice INTO gs_zprice INDEX ls_zprice-index.
IF sy-subrc EQ 0.
v_tabix = sy-tabix.
gs_zprice-crmemo = salesdocument.
MODIFY gt_zprice
FROM gs_zprice INDEX v_tabix TRANSPORTING crmemo.
ENDIF.
ENDLOOP.
CLEAR gt3_zprice.
LOOP AT gt_zprice.
wa-vkorg = gt_zprice-vkorg.
wa-vtweg = gt_zprice-vtweg.
wa-spart = gt_zprice-spart.
wa-kunnr = gt_zprice-kunnr.
wa-matnr = gt_zprice-matnr.
wa-crdate = gt_zprice-crdate.
wa-efdate = gt_zprice-efdate.
wa-sprice = gt_zprice-sprice.
wa-eprice = gt_zprice-eprice.
wa-eohqty = gt_zprice-eohqty.
wa-aohqty = gt_zprice-aohqty.
wa-auart = gt_zprice-auart.
wa-bstkd = gt_zprice-bstkd.
wa-werks = gt_zprice-werks.
wa-augru = gt_zprice-augru.
wa-xblnr = gt_zprice-xblnr.
wa-crmemo = gt_zprice-crmemo.
MODIFY zppprice FROM wa.
CLEAR: wa, zppprice.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form Displaydata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM displaydata.
SET PF-STATUS 'LIST'.
NEW-PAGE LINE-SIZE 253.
SELECT * FROM zppprice
INTO TABLE gt_zprice.
WRITE: /01(253) sy-uline.
LOOP AT gt_zprice INTO gs_zprice.
SELECT SINGLE name1 FROM kna1 INTO kna1-name1
WHERE kunnr = gs_zprice-kunnr.
WRITE: /01 sy-vline,
02 chbox AS CHECKBOX,
04 sy-vline,
05 gs_zprice-vkorg,
10 sy-vline,
11 gs_zprice-vtweg,
14 sy-vline,
15 gs_zprice-spart,
18 sy-vline,
19 gs_zprice-kunnr,
30 sy-vline,
31 kna1-name1,
67 sy-vline,
68 gs_zprice-matnr,
87 sy-vline,
88 gs_zprice-crdate,
98 sy-vline,
99 gs_zprice-efdate,
110 sy-vline,
111 gs_zprice-sprice,
127 sy-vline,
128 gs_zprice-eprice,
145 sy-vline,
146 gs_zprice-eohqty,
157 sy-vline,
158 gs_zprice-aohqty,
169 sy-vline,
170 gs_zprice-auart,
175 sy-vline,
176 gs_zprice-bstkd,
212 sy-vline,
213 gs_zprice-werks,
218 sy-vline,
219 gs_zprice-augru,
223 sy-vline,
224 gs_zprice-xblnr,
241 sy-vline,
242 gs_zprice-crmemo,
253 sy-vline.
ENDLOOP.
WRITE: /01(253) sy-uline.
CLEAR gt_zprice.
ENDFORM. " Displaydata
08-23-2007 9:56 PM
Hi Neelu,
No issues..
Just keep one more structure like ty_zstructure with check box ( I do not want to distrb main Internal table ),this structure will have check box.
now pass what ever data you have gt_zprice to new internal table.
now use this internal table to gt5_zprice,so you get everything here.
I can't code since your program has custom table otherwise i can modify the code .
Look at previous reply ,it has small program,use same logic for you new structure.
Good Luck
Thanks
Seshu
08-24-2007 12:48 AM
Hi Seshu,
I changed it and when I debug now I have chbox = X in header but when I append it is not updating the record in itab.
LOOP AT gt5_zprice.
gt5_zprice-chbox = 'X'.
APPEND gt5_zprice.
ENDLOOP.
Please guide me why it is not updating the itab.
When submit comes to this program, it goes to display data and first displays the data of the custom table. My custom table has same fields as ty_zprice other than index.
Thanks,
Neelu.
TABLES: zppprice, kna1.
TYPES: BEGIN OF ty_zprice,
mandt TYPE mandt,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
spart TYPE spart,
kunnr TYPE kunnr,
matnr TYPE matnr,
crdate TYPE zcrdate,
efdate TYPE zefdate,
sprice TYPE zprice3,
eprice TYPE zprice4,
eohqty TYPE zquantity1,
aohqty TYPE zquantity2,
auart TYPE auart,
bstkd TYPE bstkd,
werks TYPE werks_d,
augru TYPE augru,
xblnr TYPE xblnr,
crmemo TYPE vbeln,
index TYPE sy-index,
END OF ty_zprice.
TYPES: BEGIN OF ty5_zprice,
mandt TYPE mandt,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
spart TYPE spart,
kunnr TYPE kunnr,
matnr TYPE matnr,
crdate TYPE zcrdate,
efdate TYPE zefdate,
sprice TYPE zprice3,
eprice TYPE zprice4,
eohqty TYPE zquantity1,
aohqty TYPE zquantity2,
auart TYPE auart,
bstkd TYPE bstkd,
werks TYPE werks_d,
augru TYPE augru,
xblnr TYPE xblnr,
crmemo TYPE vbeln,
index TYPE sy-index,
chbox(1) TYPE c,
END OF ty5_zprice.
DATA: gt_zprice TYPE TABLE OF zppprice WITH HEADER LINE,
gt2_zprice TYPE TABLE OF ty_zprice WITH HEADER LINE,
gt3_zprice TYPE TABLE OF ty_zprice,
gt4_zprice TYPE TABLE OF ty_zprice WITH HEADER LINE,
gs_zprice TYPE zppprice,
gs_zprice1 TYPE ty_zprice,
ls_zprice TYPE ty_zprice,
wa LIKE zppprice,
gt5_zprice TYPE TABLE OF ty5_zprice WITH HEADER LINE,
gt1_zprice TYPE TABLE OF ty5_zprice WITH HEADER LINE,
gs5_zprice TYPE ty5_zprice.
DATA: salesdocument TYPE bapivbeln-vbeln.
DATA: header LIKE bapisdhd1.
DATA: headerx LIKE bapisdhd1x.
DATA: item LIKE bapisditm OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditmx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapiparnr OCCURS 0 WITH HEADER LINE.
DATA: return1 LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: conditions1 LIKE bapicond OCCURS 0 WITH HEADER LINE.
DATA: order_text LIKE bapisdtext OCCURS 0 WITH HEADER LINE.
DATA: lv_index TYPE sy-index,
v_tabix TYPE sytabix,
chbox(1) TYPE c VALUE ' ',
repid TYPE sy-repid,
lv_itemno TYPE i VALUE 10,
lv_pprice TYPE zprice3,
lv_lines TYPE i,
lv_flg TYPE c,
lv_cnt TYPE i.
RANGES r_date FOR sy-datum.
repid = sy-repid.
PERFORM displaydata.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'SELE'.
SET PF-STATUS 'STAT'.
r_date-low = sy-datum - 7.
r_date-high = sy-datum.
r_date-option = 'BT'.
r_date-sign = 'I'.
APPEND r_date.
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
LOOP AT gt5_zprice.
gt5_zprice-chbox = 'X'.
APPEND gt5_zprice.
ENDLOOP.
SELECT * FROM zppprice INTO TABLE gt1_zprice.
LOOP AT gt1_zprice.
gt1_zprice-chbox = ' '.
APPEND gt1_zprice.
ENDLOOP.
APPEND LINES OF gt1_zprice TO gt5_zprice.
SET PF-STATUS 'LIST'.
NEW-PAGE LINE-SIZE 253.
WRITE: /01(253) sy-uline.
LOOP AT gt5_zprice INTO gs5_zprice.
WRITE: /01 sy-vline,
02 gs5_zprice-chbox,
04 sy-vline,
05 gs5_zprice-vkorg,
10 sy-vline,
11 gs5_zprice-vtweg,
14 sy-vline,
15 gs5_zprice-spart,
18 sy-vline,
19 gs5_zprice-kunnr,
30 sy-vline,
31 kna1-name1,
67 sy-vline,
68 gs5_zprice-matnr,
87 sy-vline,
88 gs5_zprice-crdate,
98 sy-vline,
99 gs5_zprice-efdate,
110 sy-vline,
111 gs5_zprice-sprice,
127 sy-vline,
128 gs5_zprice-eprice,
145 sy-vline,
146 gs5_zprice-eohqty,
157 sy-vline,
158 gs5_zprice-aohqty,
169 sy-vline,
170 gs5_zprice-auart,
175 sy-vline,
176 gs5_zprice-bstkd,
212 sy-vline,
213 gs5_zprice-werks,
218 sy-vline,
219 gs5_zprice-augru,
223 sy-vline,
224 gs5_zprice-xblnr,
241 sy-vline,
242 gs5_zprice-crmemo,
253 sy-vline.
ENDLOOP.
WRITE: /01(253) sy-uline.
08-24-2007 5:46 PM
Hello Neelu,
issue at your loop .
SELECT * FROM zppprice INTO TABLE gt5_zprice
WHERE crdate IN r_date.
LOOP AT gt5_zprice.
gt5_zprice-chbox = 'X'.
Modify gt5_zprice. Should not write Append command ( since same internal table within loop ,append will not work
ENDLOOP.
SELECT * FROM zppprice INTO TABLE gt1_zprice.
LOOP AT gt1_zprice.
gt1_zprice-chbox = ' '.
modify gt1_zprice. Should not write Append command ( since same internal table within loop ,append will not work
ENDLOOP.
APPEND LINES OF gt1_zprice TO gt5_zprice.
Thanks
Seshu
09-05-2007 7:22 PM
Hi Seshu,
Sorry for the very late reply. Now I can check the check boxes in the Date Range, but I ran in to different Issues. I am going to work on the new Issues.
I really appreciate your help.
Thanks,
Neelu.