Append to Ztable
i create a ztable, i 'm running the prog and it insert rows.
when i running the report againg it is not inserting rows, it not making append to the data in the table
this is a new ztable that i create what wrong?
hi
chk the following sap help
Inserting into the Database
Variants:
1. INSERT INTO dbtab VALUES wa. oder
INSERT INTO (dbtabname) VALUES wa. oder
INSERT dbtab FROM wa. oder
INSERT (dbtabname) FROM wa.
2. INSERT dbtab FROM TABLE itab. oder
INSERT (dbtabname) FROM TABLE itab.
3. INSERT dbtab. oder
INSERT *dbtab.
Effect
Inserts new lines in a database table (see relational database). You can specify the name of the database table either in the program itself in the form dbtab or at runtime as the contents of the variable dbtabname. In both cases, the database table must be defined in the ABAP Dictionary. By default, data is only inserted in the current client. Data can only be inserted using a view if the view refers to a single table and was defined in the ABAP Dictionary with the maintenance status "No restriction".
INSERT belongs to the Open SQL command set.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs.See Open SQL and Unicode.
Notes
You cannot insert a line if a line with the same primary key already exists or if a UNIQUE index already has a line with identical key field values (with regard to this UNIQUE index).
When inserting lines using a view, all fields of the
database table that are not in the view are set to their initial value
(see TABLES) - if they were defined with NOT NULL in the ABAP Dictionary. Otherwise they are set to NULL.
Authorization checks (see The SAP Authorization Concept) are not supported by the INSERT statement. You must include these in the program yourself.
Lines specified with the INSERT command are not finally added to the database table until after a database commit (see Logical Unit of Work (LUW)). Prior to this, you can cancel any changes to the database with a database rollback (see Programming Transactions).
In the dialog system, you cannot rely on the locking mechanism used by the database system (see Database Locking) to synchronize simultaneous access to the same database by several users. Therefore, it is often necessary to use SAP's locking mechanism (see SAP Locking).
Variant 1
INSERT INTO dbtab VALUES wa. or
INSERT INTO (dbtabname) VALUES wa. or
INSERT dbtab FROM wa. or
INSERT (dbtabname) FROM wa.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
Effect
Inserts one line into a database table. The line to be inserted is taken from the work area wa and the data read from left to right according to the line structure of the database table dbtab. Here, the structure of wa is not taken into account. For this reason, the work area wa must be at least as wide (see DATA) as the line structure of dbtab, and the alignment of the work area wa must correspond to the alignment of the line structure. Otherwise, a runtime error occurs.
If the database table dbtab or the work area wa contain strings, wa must be compatible with the line structure of dbtab.
When the command has been executed, the system field SY-DBCNT contains the number of inserted lines (0 or 1).
The Return Code is set as follows:
SY-SUBRC = 0:
Line was successfully inserted.
SY-SUBRC = 4:
Line could not be inserted since a line with the same key already exists.
Example
Insert the customer Robinson in the current client:
DATA: wa TYPE scustom.
wa-id = '12400177'.
wa-name = 'Robinson'.
wa-postcode = '69542'.
wa-city = 'Heidelberg'.
wa-custtype = 'P'.
wa-discount = '003'.
wa-telephone = '06201/44889'.
INSERT INTO scustom VALUES wa.
Addition 1
... CLIENT SPECIFIED
Effect
Automatic client handling is switched off. This allows
you to process data on a cross-client basis for client-specific tables. The client field is then treated like a normal table field which the program must fill with values in the work area wa.
The addition CLIENT SPECIFIED must be specified directly after the name of the database table.
Example
Insert the customer Robinson in client 2:
DATA: wa TYPE scustom.
wa-mandt = '002'.
wa-id = '12400177'.
wa-name = 'Robinson'.
wa-postcode = '69542'.
wa-city = 'Heidelberg'.
wa-custtype = 'P'.
wa-discount = '003'.
wa-telephone = '06201/44889'.
INSERT scustom CLIENT SPECIFIED FROM wa.
Addition 2
... CONNECTION con
Effect
The Open SQL command is not executed on the
standard database, but on the secondary database connection specified with con. con is the name of the databse connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text), where the field source_text contains the name of the database connection and must be type C or STRING. The CONNECTION con addition must be specified directly after the name of the database table or after the CLIENT SPECIFIED addition.
Variant 2
INSERT dbtab FROM TABLE itab. oder
INSERT (dbtabname) FROM TABLE itab.
Extras:
1. ... CLIENT SPECIFIED
2. ... ACCEPTING DUPLICATE KEYS
3. ... CONNECTION con
Effect
Mass insert: All lines of the internal table itab are inserted in one single operation. The lines of itab must fulfill the same conditions as the work area wa in variant 1.
When the command has been executed, the system field SY-DBCNT contains the number of inserted lines.
The Return Code is set as follows:
SY-SUBRC = 0:
All lines successfully inserted. Any other result causes a runtime error.
Note
If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0 after the call.
Addition 1
... CLIENT SPECIFIED
Effect
As with variant 1.
Addition 2
... ACCEPTING DUPLICATE KEYS
Effect
If a line cannot be inserted, the system does not
terminate with a runtime error but only sets the return value SY-SUBRC to 4. All other lines are inserted after the command is executed.
Addition 3
... CONNECTION con
Effect
As with variant 1.
Variant 3
INSERT dbtab. or
INSERT *dbtab.
Extras:
1. ... CLIENT SPECIFIED
2. ... CONNECTION con
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas.
See Cannot Use Short Forms and Cannot Use * Work Areas.
Note
This variant is obsolete.
Effect
These are the SAP-specific short forms of variant 1. They have the same effect as variant 1, but the work area is not specified explicitly. Instead, the system implicitly uses the table work area dbtab or *dbtab declared using a TABLES statement.
INSERT dbtab. bzw.
INSERT *dbtab.
is equivalent to
INSERT INTO dbtab VALUES dbtab. or
INSERT INTO dbtab VALUES *dbtab.
When the command has been executed, the system field SY-DBCNT contains the number of lines inserted (0 or 1).
The Return Code is set as follows:
SY-SUBRC = 0:
Line successfully inserted.
SY-SUBRC = 4:
Line could not be inserted, since a line with the same key already exists.
Example
Add a line to a database table:
TABLES sairport.
sairport-id = 'NEW'.
sairport-name = 'NEWPORT APT'.
INSERT sairport.
Notes
You should always use variant 1 where you specify an explicit work area wa instead of using the implicit TABLES work area.
If a work area is not explicitly specified, the values for the line to be inserted are taken from the table work area dbtab if the statement is in a FORM or FUNCTION where the table work area is stored in a formal parameter or local variable of the same name.
Addition 1
... CLIENT SPECIFIED
Effect
As with variant 1.
Addition 2
... CONNECTION con
Effect
As with variant 1.
regards
ganesh
Similar Messages
-
Query related to database tables
Hi,
Im having a requirement wherein i would like to create one ztable and the purpose is only to get the fields but not the values for the same. Bez, with the help of these fields in ztable and developing some logic and it shld be dynamic based on the no of fields appended into ztable.
To be clear, can i write a select query only to get the fields from the table but not the values ( in this no way i will get the values bez i won't insert any records for the same).
I thnk im clear from my end.
Thanks
rohithTo get the fields, you can write the query like this too :
tables: dd03l.
data: begin of itab occurs 0,
fieldname like dd03l-fieldname,
end of itab.
*parameters: p_tab like dd03l-tabname.
select fieldname from dd03l into table itab where tabname = 'VBAK'.
LOOP AT ITAB.
WRITE:/ itab-fieldname.
ENDLOOP. -
Dear all Abaper,
I'm beginer for abap about six month since my office implement sap. I've make abap program to get data from
any table of sap like vbak,vbap,ekko, ekpo etc to z table.
Now i want to get data from excel or text file to append in ztable. I've learn about LSMW but not yet found
how to import to z table. LSMW have standart template import to standart sap table.
Could abap guru help me to solve this problem?
Regards
WiliDear Chitta,
I've tried using abap program like this:
REPORT ZWIL_IMPORT_EXCEL_TO_ZTABLE2.
TYPE-POOLS TRUXS.
tables zwilharga2.
PARAMETER P_FILE TYPE RLGRAP-FILENAME DEFAULT
'D:\SAPBELAJAR\coba1.xls'.
DATA : IT_RAW TYPE truxs_t_text_data,wa type zwilharga2,IT_ITAB TYPE TABLE OF zwilharga2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
start-of-selection.
break-point.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 6
I_END_ROW = 25
TABLES
INTERN = it_itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = it_itab[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
break-point.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
end-of-selection.
Display error "Illegal type when transferring an internal table to a FORM"
Thanx
Wili -
hi all,
i have one ztable. .
for this i have to append structure with 3 new fields to that ztable.
can u plz tell me how to do it.Hi
To add fields to the Z Table using Append Structure then open the table in Change mode in SE11 and
click on APPEND STRUCTURE Button on the Application Toolbar. It will prompt you to enter the name of the Append Structure. Enter the name and then define the fields in the structure and activate the table.
The fields in the Append Structure must start with "ZZ" (Eg...ZZdate1 etc..)
Hope it helps.
Murthy -
Upload data from excel to Ztable with statistics
Hi,
I have a requirement to upload data from excel sheet to ztable .
Here i need tp provide the user with the execution statistics like
1.Number of records read from the Excel spread-sheet
2. Number records processed successfully
3. Number records with Error
4. Name and location of Error Log-file (text-file format)
5. Name and location of the file containing error records (Excel spread-sheet format)
I would appreciate if any of you have code written for the sameSee the below example code to upload from xl file to sap
REPORT ZLWMI151_UPLOAD no standard page heading
line-size 100 line-count 60.
*tables : zbatch_cross_ref.
data : begin of t_text occurs 0,
werks(4) type c,
cmatnr(15) type c,
srlno(12) type n,
matnr(7) type n,
charg(10) type n,
end of t_text.
data: begin of t_zbatch occurs 0,
werks like zbatch_cross_ref-werks,
cmatnr like zbatch_cross_ref-cmatnr,
srlno like zbatch_cross_ref-srlno,
matnr like zbatch_cross_ref-matnr,
charg like zbatch_cross_ref-charg,
end of t_zbatch.
data : g_repid like sy-repid,
g_line like sy-index,
g_line1 like sy-index,
$v_start_col type i value '1',
$v_start_row type i value '2',
$v_end_col type i value '256',
$v_end_row type i value '65536',
gd_currentrow type i.
data: itab like alsmex_tabline occurs 0 with header line.
data : t_final like zbatch_cross_ref occurs 0 with header line.
selection-screen : begin of block blk with frame title text.
parameters : p_file like rlgrap-filename obligatory.
selection-screen : end of block blk.
initialization.
g_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = g_repid
IMPORTING
FILE_NAME = p_file.
start-of-selection.
Uploading the data into Internal Table
perform upload_data.
perform modify_table.
top-of-page.
CALL FUNCTION 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
*& Form upload_data
text
FORM upload_data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = $v_start_col
I_BEGIN_ROW = $v_start_row
I_END_COL = $v_end_col
I_END_ROW = $v_end_row
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write:/10 'File '.
ENDIF.
if sy-subrc eq 0.
read table itab index 1.
gd_currentrow = itab-row.
loop at itab.
if itab-row ne gd_currentrow.
append t_text.
clear t_text.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'.
t_text-werks = itab-value.
when '0002'.
t_text-cmatnr = itab-value.
when '0003'.
t_text-srlno = itab-value.
when '0004'.
t_text-matnr = itab-value.
when '0005'.
t_text-charg = itab-value.
endcase.
endloop.
endif.
append t_text.
ENDFORM. " upload_data
*& Form modify_table
Modify the table ZBATCH_CROSS_REF
FORM modify_table.
loop at t_text.
t_final-werks = t_text-werks.
t_final-cmatnr = t_text-cmatnr.
t_final-srlno = t_text-srlno.
t_final-matnr = t_text-matnr.
t_final-charg = t_text-charg.
t_final-erdat = sy-datum.
t_final-erzet = sy-uzeit.
t_final-ernam = sy-uname.
t_final-rstat = 'U'.
append t_final.
clear t_final.
endloop.
delete t_final where werks = ''.
describe table t_final lines g_line.
sort t_final by werks cmatnr srlno.
Deleting the Duplicate Records
perform select_data.
describe table t_final lines g_line1.
modify zbatch_cross_ref from table t_final.
if sy-subrc ne 0.
write:/ 'Updation failed'.
else.
Skip 1.
Write:/12 'Updation has been Completed Sucessfully'.
skip 1.
Write:/12 'Records in file ',42 g_line .
write:/12 'Updated records in Table',42 g_line1.
endif.
delete from zbatch_cross_ref where werks = ''.
ENDFORM. " modify_table
*& Form select_data
Deleting the duplicate records
FORM select_data.
select werks
cmatnr
srlno from zbatch_cross_ref
into table t_zbatch for all entries in t_final
where werks = t_final-werks
and cmatnr = t_final-cmatnr
and srlno = t_final-srlno.
sort t_zbatch by werks cmatnr srlno.
loop at t_zbatch.
read table t_final with key werks = t_zbatch-werks
cmatnr = t_zbatch-cmatnr
srlno = t_zbatch-srlno.
if sy-subrc eq 0.
delete table t_final .
endif.
clear: t_zbatch,
t_final.
endloop.
ENDFORM. " select_data
Reward Points if it is helpful
Thanks
Seshu -
Dialogue program for modifying ztable
hi experts,
i want to create a ztable. After creating the ztable i want to create an dialogue program using that dialogue program i have to create/modify entries of that ztable using text box and push button options.
can anybody having sample coding pls send me.....
thanks in advance,
raviHI,
chek this sample code
data: begin of itab occurs 0.
include structure ZTESTVENKATESH.
data: end of itab.
call screen 100.
*& Module STATUS_0100 OUTPUT
text
module STATUS_0100 output.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module USER_COMMAND_0100 input.
if sy-ucomm = 'HAI'.
APPEND ITAB.
modify ZTESTVENKATESH from table itab.
ENDIF.
thanks & regards,
venkatesh -
How to find when a ztable gets populated?
Hi Folks,
Closing balance not carrying forward to Opening Balance-MM
Previously I posted a question with the above said subject.But couldn't get any right lead.
The problem is we have developed a zreport to get the RG1 summary of finished goods.For that the previous team who worked on this had copied the table
j_2irg1bal to z2irg1bal.I want to know when and how this ztable will get populated.
Can anyone here please go through the BOLD part of this code and let me know.
K.Kiran.
REPORT zxxx MESSAGE-ID z_apd.
*& Includes *
INCLUDE <icon>.
*& Tables *
TABLES : j_1irg1,
j_2irg1bal,
z2irg1bal,
ser03,
objk.
*& Selection Screen *
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
PARAMETERS : p_exgrp TYPE j_1irg1-exgrp OBLIGATORY,
p_stdate LIKE sy-datum OBLIGATORY,
p_endate LIKE sy-datum OBLIGATORY.
SELECT-OPTIONS s_chapid FOR j_1irg1-chapid .
SELECTION-SCREEN : END OF BLOCK blk1.
*& Data Declaration *
Internal Tables
DATA : it_display TYPE TABLE OF zj1irg1,
it_final TYPE TABLE OF zj1irg1,
it_alv TYPE TABLE OF zj1irg1,
Work Areas
wa_display TYPE zj1irg1,
wa_alv TYPE zj1irg1,
it_display1 TYPE TABLE OF zj1irg1,
wa_display1 TYPE zj1irg1,
wa_alv1 TYPE zj1irg1.
DATA: BEGIN OF it_itab OCCURS 0.
INCLUDE STRUCTURE zj1irg1.
DATA: END OF it_itab.
DATA : BEGIN OF itab1 OCCURS 0,
matnr LIKE j_1irg1-matnr,
END OF itab1.
DATA : BEGIN OF itab2 OCCURS 0,
cpudt LIKE j_1irg1-cpudt,
END OF itab2.
DATA : BEGIN OF itab3 OCCURS 0.
INCLUDE STRUCTURE j_1irg1.
DATA: END OF itab3.
DATA : itab4 LIKE j_1irg1 OCCURS 0 WITH HEADER LINE,
itab5 LIKE j_1irg1 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF itab6 OCCURS 0.
INCLUDE STRUCTURE j_1irg1.
DATA : sernr LIKE objk-sernr.
DATA: END OF itab6.
DATA : BEGIN OF itab61 OCCURS 0.
INCLUDE STRUCTURE j_1irg1.
DATA: sernr LIKE objk-sernr.
DATA: END OF itab61.
DATA : itab7 LIKE j_2irg1bal OCCURS 0 WITH HEADER LINE,
it_bal LIKE j_2irg1bal OCCURS 0 WITH HEADER LINE,
it_bal1 LIKE j_2irg1bal OCCURS 0 WITH HEADER LINE.
DATA: qty_menge LIKE j_1irg1-menge,
iss_menge LIKE j_1irg1-menge,
tot_menge LIKE j_1irg1-menge,
op_menge LIKE j_1irg1-menge,
matnr LIKE j_1irg1-matnr,
exgrp LIKE j_1irg1-exgrp ,
cpudt LIKE j_1irg1-cpudt.
*for checcking lines of itab
DATA: n1 TYPE i.
Others
DATA : v_bwart TYPE mseg-bwart,
v_index TYPE i,
v_index1 TYPE i,
count(4) TYPE n VALUE '0',
neg TYPE char1 VALUE '-',
menge TYPE char16,
count_1 TYPE i,
count_2 TYPE i,
count_3 TYPE i,
count12(4) TYPE n VALUE '0',
count13(4) TYPE n VALUE '0'.
*Ranges
RANGES: v_bwart1 FOR mseg-bwart.
For ALV Display
DATA : gs_variant TYPE disvariant,
gs_layout TYPE lvc_s_layo,
c_stk TYPE scrfname VALUE 'ZRG1',
custom_container TYPE REF TO cl_gui_custom_container.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA : grid1 TYPE REF TO cl_gui_alv_grid,
event_receiver TYPE REF TO lcl_event_receiver,
ok_code TYPE sy-ucomm,
it_fieldcatalog TYPE lvc_t_fcat,
wafieldcatlog TYPE LINE OF lvc_t_fcat,
lt_rows TYPE lvc_t_row,
wa_rows TYPE LINE OF lvc_t_row.
*& Start of Selection *
START-OF-SELECTION.
IMPORT s_chapid FROM MEMORY ID 'SCHAPID'.
PERFORM get_data.
IF it_display[] IS INITIAL.
No Details Available
MESSAGE i017(z_apd) WITH text-005.
STOP.
ELSE.
Display the Details on the Screen
sort it_display by matnr.
*sort it_display by cpudt RISINDR RISINDI matnr.
<b>LOOP AT it_display INTO wa_display.
ON CHANGE OF wa_display-matnr.
*insert
*Check record exits
SELECT SINGLE * FROM z2irg1bal
WHERE
exgrp = exgrp AND
matnr = matnr AND
form = 'P' AND
cb_finish = tot_menge AND
datum = cpudt.
*If record does not exists
*Update balance Table.
IF count12 GE 1.
IF sy-subrc NE 0.
z2irg1bal-mandt = sy-mandt.
z2irg1bal-exgrp = exgrp.
z2irg1bal-matnr = matnr.
z2irg1bal-form = 'P'.
z2irg1bal-cb_finish = tot_menge.
z2irg1bal-datum = cpudt.
INSERT z2irg1bal ."values wa_display.
COMMIT WORK.
ENDIF.
Start of Insertion
IF sy-subrc EQ 0.
z2irg1bal-mandt = sy-mandt.
z2irg1bal-exgrp = exgrp.
z2irg1bal-matnr = matnr.
z2irg1bal-form = 'P'.
z2irg1bal-cb_finish = tot_menge.
z2irg1bal-datum = cpudt.
UPDATE z2irg1bal SET cb_finish = z2irg1bal-cb_finish
WHERE exgrp = z2irg1bal-exgrp AND
datum = z2irg1bal-datum AND
matnr = z2irg1bal-matnr AND
form = 'P'.
ENDIF.
End of Insertion.
ENDIF.</b>CLEAR: qty_menge,
iss_menge,
tot_menge,
count,
matnr,
cpudt,
exgrp.
ENDON.
loop at itab6.
AT NEW matnr.
v_index = 1.
count = count + 1 .
ENDAT.
IF v_index = 1.
CLEAR v_index.
*INsert for adding start
IF wa_display-risind = 'R'.
*wa_display-OP_FINISH = wa_display-OP_FINISH +
wa_display-CB_FINISH +
wa_display-MENGE.
wa_display-op_finish = wa_display-menge.
qty_menge = wa_display-op_finish.
IF wa_display-status = space.
tot_menge = tot_menge + qty_menge + wa_display-cb_finish .
ELSE.
tot_menge = tot_menge - qty_menge + wa_display-cb_finish.
ENDIF.
*tot_menge = op_menge.
op_menge = tot_menge.
ELSE.
*Qty Issued
wa_display-op_bond = wa_display-op_finish - wa_display-menge.
IF wa_display-op_bond LT 0.
iss_menge = wa_display-op_bond.
iss_menge = ABS( iss_menge ).
*Start of modification
tot_MENGE = tot_MENGE - iss_MENGE ."
IF count LE 1.
tot_menge = wa_display-cb_finish - iss_menge ."
ELSE.
tot_menge = tot_menge - iss_menge ."
ENDIF.
*End of modification
op_menge = tot_menge.
ENDIF.
ENDIF.
*wa_display-MENGE_FINI = wa_display-OP_FINISH - wa_display-OP_BOND.
*tot_MENGE = tot_MENGE + qty_MENGE - iss_MENGE .
wa_display-menge_fini = tot_menge.
**matnr for insert
matnr = wa_display-matnr.
*excise group
exgrp = wa_display-exgrp.
*Date
cpudt = wa_display-cpudt.
*Opening Balance
*Insert start
*if count le 1.
if wa_display-RISIND = 'R'.
wa_display-CB_FINISH = wa_display-CB_FINISH + qty_MENGE.
else.
wa_display-CB_FINISH = wa_display-CB_FINISH - iss_MENGE.
endif.
*endif.
*Insert End
IF count GT 1.
IF wa_display-risind = 'R'.
wa_display-cb_finish = tot_menge - qty_menge.
ELSE.
wa_display-cb_finish = tot_menge + iss_menge.
ENDIF.
ENDIF.
*check it_display-SERIALNO = wa_display-SERIALNO.
MODIFY it_display FROM wa_display.
*INsert for adding end
*move-corresponding wa_display to it_itab.
*append it_itab.
*check it_itab-SERIALNO = wa_display-SERIALNO.
*if sy-subrc = 0.
*endif.
*Insert to update closng to balance to Rg1bal table
*start
count12 = count12 + 1.
*for last record
AT LAST.
*Check record exits
SELECT SINGLE * FROM z2irg1bal
WHERE
exgrp = exgrp AND
matnr = matnr AND
form = 'P' AND
cb_finish = tot_menge AND
datum = cpudt.
*If record does not exists
*Update balance Table.
IF count12 GE 1.
IF sy-subrc NE 0.
z2irg1bal-mandt = sy-mandt.
z2irg1bal-exgrp = exgrp.
z2irg1bal-matnr = matnr.
z2irg1bal-form = 'P'.
z2irg1bal-cb_finish = tot_menge.
z2irg1bal-datum = cpudt.
INSERT z2irg1bal ."values wa_display.
COMMIT WORK.
Start of Insertion
IF sy-subrc EQ 0.
z2irg1bal-mandt = sy-mandt.
z2irg1bal-exgrp = exgrp.
z2irg1bal-matnr = matnr.
z2irg1bal-form = 'P'.
z2irg1bal-cb_finish = tot_menge.
z2irg1bal-datum = cpudt.
UPDATE z2irg1bal SET cb_finish = z2irg1bal-cb_finish
WHERE exgrp = z2irg1bal-exgrp AND
datum = z2irg1bal-datum AND
matnr = z2irg1bal-matnr AND
form = 'P'.
ENDIF.
End of Insertion
ENDIF.
ENDIF.
ENDAT.
*Insert to update closng to balance to Rg1bal table
*end
MOVE-CORRESPONDING wa_display TO wa_alv.
APPEND wa_alv TO it_alv.
append itab6 to it_alv.
ENDIF.
ENDLOOP.
loop at it_alv into wa_alv.
wa_alv-exgrp = wa_alv-exgrp.
wa_alv-SYEAR = wa_alv-syear.
wa_alv-SERIALNO = wa_alv-SERIALNO.
endloop.
EXPORT it_alv TO MEMORY ID 'ABCD'.
call screen 100.
ENDIF.
*& End of Selection *
END-OF-SELECTION.
*& Class Definition *
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
*& Class Implementation *
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
Local Variables
DATA: ls_toolbar TYPE stb_button.
append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
append an icon to to show printing
CLEAR ls_toolbar.
MOVE 'PRINT' TO ls_toolbar-function.
MOVE icon_print TO ls_toolbar-icon.
MOVE 'Print Receipts' TO ls_toolbar-quickinfo.
MOVE ' Print' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. " Handle_toolbar
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'PRINT'.
REFRESH : lt_rows , it_final.
CALL METHOD grid1->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
LOOP AT lt_rows INTO wa_rows.
READ TABLE it_alv INDEX wa_rows-index INTO wa_alv.
LOOP AT it_display INTO wa_display
WHERE mblnr = wa_alv-mblnr.
APPEND wa_display TO it_final.
ENDLOOP.
ENDLOOP.
perform display_form.
ENDCASE.
ENDMETHOD. "handle_user_command
METHOD handle_double_click.
IF e_column = 'MBLNR'.
READ TABLE it_alv INDEX e_row-index INTO wa_alv.
IF sy-subrc = 0.
REFRESH it_final.
LOOP AT it_display INTO wa_display
WHERE mblnr = wa_alv-mblnr.
APPEND wa_display TO it_final.
ENDLOOP.
PERFORM call_migo.
ENDIF.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data .
*Select only for matnr and chapid from table
SELECT matnr FROM j_1irg1
APPENDING CORRESPONDING FIELDS OF TABLE itab1
WHERE exgrp = p_exgrp
AND
WERKS = P_WERKS
and
MATNR in s_MATNR
and
CPUDT in s_CPUDT.
cpudt BETWEEN p_stdate AND p_endate
AND
*Chapid
chapid IN s_chapid
ORDER BY matnr.
SORT itab1 BY matnr. " for performance
DELETE ADJACENT DUPLICATES FROM itab1 COMPARING matnr .
SELECT cpudt FROM j_1irg1
APPENDING CORRESPONDING FIELDS OF TABLE itab2
WHERE exgrp = p_exgrp
AND
cpudt BETWEEN p_stdate AND p_endate
AND
*Chapid
chapid IN s_chapid
ORDER BY cpudt.
SORT itab2 BY cpudt. " for Performance
DELETE ADJACENT DUPLICATES FROM itab2 COMPARING cpudt .
LOOP AT itab1.
LOOP AT itab2.
*on change of itab1-matnr or itab2-cpudt.
*select * from J_1IRG1
CLEAR itab3.
SELECT * FROM j_1irg1
*into itab3
APPENDING CORRESPONDING FIELDS OF TABLE itab3
WHERE matnr = itab1-matnr
AND
cpudt = itab2-cpudt.
*count = count + 1.
IF sy-subrc EQ 0.
LOOP AT itab3.
*count = count + 1.
*READ TABLE itab3 INDEX count."1.
IF itab3-risind = 'R'.
MOVE-CORRESPONDING itab3 TO itab4.
APPEND itab4.
DELETE itab3.
MOVE-CORRESPONDING itab4 TO itab6.
APPEND itab6.
CLEAR itab4.
ELSE.
MOVE-CORRESPONDING itab3 TO itab5.
APPEND itab5.
DELETE itab3.
MOVE-CORRESPONDING itab5 TO itab6.
APPEND itab6.
CLEAR itab5.
ENDIF.
ENDLOOP.
ENDIF.
*endon.
ENDLOOP.
ENDLOOP.
SELECT * FROM z2irg1bal
APPENDING CORRESPONDING FIELDS OF TABLE itab7
WHERE exgrp = p_exgrp
AND
datum LE p_stdate
ORDER BY datum.
SORT itab7 BY datum.
DELETE ADJACENT DUPLICATES FROM itab7 COMPARING datum .
*insert Start
LOOP AT itab6.
DELETE itab7 WHERE matnr NE itab6-matnr.
ENDLOOP.
*insert End
*insert Start
LOOP AT itab6.
CLEAR itab61. REFRESH itab61.
CLEAR wa_display.
MOVE-CORRESPONDING itab6 TO wa_display.
EQPT Serno
count13 = 1.
SELECT SINGLE obknr FROM ser03 INTO ser03-obknr WHERE
mblnr EQ itab6-mblnr
AND mjahr EQ itab6-mjahr.
IF sy-subrc EQ 0.
SELECT sernr FROM objk INTO CORRESPONDING
FIELDS OF TABLE itab61 WHERE
obknr EQ ser03-obknr.
DESCRIBE TABLE itab61 LINES n1.
*do N1 times.
LOOP AT itab61.
IF count13 EQ 1.
wa_display-sernr = itab61-sernr.
ENDIF.
IF count13 EQ 2.
wa_display-sernr1 = itab61-sernr.
ENDIF.
IF count13 EQ 3.
wa_display-sernr2 = itab61-sernr.
ENDIF.
IF count13 EQ 4.
wa_display-sernr3 = itab61-sernr.
ENDIF.
IF count13 EQ 5.
wa_display-sernr4 = itab61-sernr.
ENDIF.
IF count13 EQ 6.
wa_display-sernr5 = itab61-sernr.
ENDIF.
IF count13 EQ 7.
wa_display-sernr6 = itab61-sernr.
ENDIF.
if count13 eq 8.
objk-SERNR8 = objk-SERNR.
endif.
if count13 eq 9.
objk-SERNR9 = objk-SERNR.
endif.
count13 = count13 + 1.
endselect.
ENDLOOP.
*enddo.
ENDIF.
endif.
*End of Modification Eqpt Serial No
MOVE-CORRESPONDING itab6 TO wa_display.
SELECT * FROM z2irg1bal
APPENDING CORRESPONDING FIELDS OF TABLE it_bal1
WHERE matnr = itab6-matnr
AND datum LE p_stdate
AND exgrp = itab6-exgrp.
SORT it_bal1 DESCENDING .
READ TABLE it_bal1 INDEX 1.
ON CHANGE OF itab6-matnr .
wa_display-cb_finish = it_bal1-cb_finish.
ENDON.
AT LAST ."matnr.
wa_display-cb_finish = it_bal1-cb_finish.
ENDAT.
APPEND wa_display TO it_display .
CLEAR wa_display-cb_finish.
CLEAR it_bal1. REFRESH it_bal1.
ENDLOOP.
SELECT * FROM j_1irg1
APPENDING CORRESPONDING FIELDS OF TABLE it_itab
WHERE exgrp = p_exgrp
AND
cpudt BETWEEN p_stdate AND p_endate.
DESCRIBE TABLE it_itab[] LINES count_1.
count_3 = count_1 + 1.
DESCRIBE TABLE it_display[] LINES count_2.
IF it_display IS NOT INITIAL.
DELETE it_display FROM count_3 TO count_2.
ENDIF.
*start of insertion
DELETE it_display WHERE status = 'C'.
LOOP AT it_display INTO wa_display.
CLEAR wa_display-cb_finish.
MODIFY it_display FROM wa_display.
ON CHANGE OF wa_display-matnr .
SELECT * FROM z2irg1bal
INTO CORRESPONDING FIELDS OF TABLE it_bal1
WHERE matnr = wa_display-matnr
AND datum LE p_stdate
AND exgrp = wa_display-exgrp.
IF sy-subrc = 0.
SORT it_bal1 DESCENDING .
READ TABLE it_bal1 INDEX 1.
wa_display-cb_finish = it_bal1-cb_finish.
MODIFY it_display FROM wa_display.
ENDIF.
ENDON.
ENDLOOP.
*End of insertion
ENDFORM. " get_data
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZRG1'.
SET TITLEBAR 'ZRG1'.
DATA: lt_exclude TYPE ui_functions.
IF custom_container IS INITIAL.
Create the Custom Container
CREATE OBJECT custom_container
EXPORTING
container_name = c_stk.
Create an instance of alv control
CREATE OBJECT grid1
EXPORTING
i_parent = custom_container.
Layout Settings
gs_layout-sel_mode = 'A'. " Multiple Lines
MOVE 'RG1 Register' TO gs_layout-grid_title.
Prepare the Field Catalog
PERFORM prepare_catalog.
To Exclude the PRINT Button from the Standard toolbar of ALV
PERFORM exclude_tb_functions CHANGING lt_exclude.
Display the List for ALV Display
CALL METHOD grid1->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
is_layout = gs_layout
CHANGING
it_fieldcatalog = it_fieldcatalog[]
it_outtab = it_alv[].
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR grid1.
SET HANDLER event_receiver->handle_toolbar FOR grid1.
SET HANDLER event_receiver->handle_double_click FOR grid1.
CALL METHOD grid1->set_toolbar_interactive.
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
ENDMODULE. " STATUS_0100 OUTPUT
*& Form exclude_tb_functions
text
<--P_LT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
Local Varaibles
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_print.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " exclude_tb_functions
*& Form prepare_catalog
text
--> p1 text
<-- p2 text
FORM prepare_catalog .
DATA : v_index TYPE i.
*Entry Date
v_index = v_index + 1.
wafieldcatlog-fieldname = 'CPUDT'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'RG1 Entry Date'.
wafieldcatlog-reptext = 'RG1 Entry Date'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Serial No
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERIALNO'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'RG1 serial number'.
wafieldcatlog-reptext = 'RG1 serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
v_index = v_index + 1.
wafieldcatlog-fieldname = 'CHAPID'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Chapter ID'.
wafieldcatlog-reptext = 'Chapter ID'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
v_index = v_index + 1.
wafieldcatlog-fieldname = 'MBLNR'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Number of Material Document'.
wafieldcatlog-reptext = 'Number of Material Document'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Item
v_index = v_index + 1.
wafieldcatlog-fieldname = 'ZEILE'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Item in Material Document'.
wafieldcatlog-reptext = 'Item in Material Document'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
v_index = v_index + 1.
wafieldcatlog-fieldname = 'BWART'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Movement Type'.
wafieldcatlog-reptext = 'Movement Type'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
v_index = v_index + 1.
wafieldcatlog-fieldname = 'MENGE'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Quantity'.
wafieldcatlog-reptext = 'Quantity'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
wafieldcatlog-DO_SUM = 'X'.
append wafieldcatlog to it_fieldcatalog.
clear wafieldcatlog-reptext.
clear wafieldcatlog-key.
*Base Unit of Measure
v_index = v_index + 1.
wafieldcatlog-fieldname = 'MEINS'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Base Unit of Measure'.
wafieldcatlog-reptext = 'Base Unit of Measure'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
wafieldcatlog-do_sum = 'X'.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
v_index = v_index + 1.
wafieldcatlog-fieldname = 'RISIND'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Goods Movement Direction'.
wafieldcatlog-reptext = 'Goods Movement Direction'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Material Number
v_index = v_index + 1.
wafieldcatlog-fieldname = 'MATNR'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Material Number'.
wafieldcatlog-reptext = 'Material Number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*CB_FINISH
v_index = v_index + 1.
wafieldcatlog-fieldname = 'CB_FINISH'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Opening Balance'.
wafieldcatlog-reptext = 'Opening Balance'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*materail manufactured
v_index = v_index + 1.
wafieldcatlog-fieldname = 'OP_FINISH'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Qty Manufactured'.
wafieldcatlog-reptext = 'Qty Manufactured'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Material Issued
v_index = v_index + 1.
wafieldcatlog-fieldname = 'OP_BOND'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Qty Issue'.
wafieldcatlog-reptext = 'Qty Issue'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Total
v_index = v_index + 1.
wafieldcatlog-fieldname = 'MENGE_FINI'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Closing Balance'.
wafieldcatlog-reptext = 'Closing Balance'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Material Description
v_index = v_index + 1.
wafieldcatlog-fieldname = 'MAKTX'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Material Description'.
wafieldcatlog-reptext = 'Material Description'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Storage Location
v_index = v_index + 1.
wafieldcatlog-fieldname = 'LGORT'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Storage Location'.
wafieldcatlog-reptext = 'Storage Location'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Goods Movement Direction
v_index = v_index + 1.
wafieldcatlog-fieldname = 'RISIND'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Goods Movement Direction'.
wafieldcatlog-reptext = 'Goods Movement Direction'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Reference Document 1
v_index = v_index + 1.
wafieldcatlog-fieldname = 'RDOC1'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Reference Document 1'.
wafieldcatlog-reptext = 'Reference Document 1'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Excise Duty Base Amount
v_index = v_index + 1.
wafieldcatlog-fieldname = 'EXBAS'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Excise Duty Base Amount'.
wafieldcatlog-reptext = 'Excise Duty Base Amount'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Basic Excise Duty
v_index = v_index + 1.
wafieldcatlog-fieldname = 'EXBED'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Basic Excise Duty'.
wafieldcatlog-reptext = 'Basic Excise Duty'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Additional Excise Duty
v_index = v_index + 1.
wafieldcatlog-fieldname = 'EXAED'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Additional Excise Duty'.
wafieldcatlog-reptext = 'Additional Excise Duty'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Special Excise Duty
v_index = v_index + 1.
wafieldcatlog-fieldname = 'EXSED'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Special Excise Duty'.
wafieldcatlog-reptext = 'Special Excise Duty'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*Cess amount
v_index = v_index + 1.
wafieldcatlog-fieldname = 'CESS'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Cess amount'.
wafieldcatlog-reptext = 'Cess amount'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*ECS Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'ECS'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'ECS Value'.
wafieldcatlog-reptext = 'ECS Value'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
**Register Entry Status
v_index = v_index + 1.
wafieldcatlog-fieldname = 'STATUS'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Register Entry Status'.
wafieldcatlog-reptext = 'Register Entry Status'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
append wafieldcatlog to it_fieldcatalog.
clear wafieldcatlog-reptext.
clear wafieldcatlog-key.
*EQPT Serno 1 Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERNR'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Serial number'.
wafieldcatlog-reptext = 'Serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*EQPT Serno 2 Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERNR1'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Serial number'.
wafieldcatlog-reptext = 'Serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*EQPT Serno 3 Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERNR2'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Serial number'.
wafieldcatlog-reptext = 'Serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*EQPT Serno 4 Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERNR3'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Serial number'.
wafieldcatlog-reptext = 'Serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*EQPT Serno 5 Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERNR4'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Serial number'.
wafieldcatlog-reptext = 'Serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*EQPT Serno 6 Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERNR5'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Serial number'.
wafieldcatlog-reptext = 'Serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
*EQPT Serno 7 Value
v_index = v_index + 1.
wafieldcatlog-fieldname = 'SERNR6'.
wafieldcatlog-tabname = 'IT_ALV'.
wafieldcatlog-seltext = 'Serial number'.
wafieldcatlog-reptext = 'Serial number'.
wafieldcatlog-hotspot = ' '.
wafieldcatlog-col_pos = v_index.
APPEND wafieldcatlog TO it_fieldcatalog.
CLEAR wafieldcatlog-reptext.
CLEAR wafieldcatlog-key.
ENDFORM. " prepare_catalog
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
IF ok_code = 'EXIT'.
CALL METHOD grid1->free.
CALL METHOD cl_gui_cfw=>flush.
leave program .
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form call_migo
text
--> p1 text
<-- p2 text
FORM call_migo .
CALL FUNCTION 'MIGO_DIALOG' "n547170
EXPORTING "n547170
i_action = 'A04' "n547170
i_refdoc = 'R02' "n547170
i_notree = 'X' "n547170
i_no_auth_check = ' ' "n547170
i_deadend = 'X' "n547170
i_skip_first_screen = 'X' "n547170
i_okcode = 'OK_GO' "n547170
i_mblnr = wa_alv-mblnr "n547170
i_mjahr = wa_alv-mjahr . "n547170
ENDFORM. " call_migoThanks,
K.Kiran -
Update ZTable from editable ALV
Hi All,
i'm calling a Function Module from within a Badi Class ( Workorder_Update) which uses an ALV to Add Comments in a Field of the ALV for Transportation to a ZTable. Therefore the ALV is set to editable.
The Problem is that if the User does not press 'enter' after she/he added the Comment, the value is not send back to the internal Table wich updates the ZTab. If the User presses 'enter' ONLY the Comment is transported but the remainder of the Fields are cleared.
This is part of the Coding:
Before Calling FM -->
+ IF wa_header_old-pronr NE wa_header-pronr.
CLEAR wa_zthlog.
wa_zthlog-uzeit = sy-uzeit.
wa_zthlog-aufnr = wa_header-aufnr.
wa_zthlog-objnr = wa_header-objnr.
wa_zthlog-vornr = wa_operation-vornr.
wa_zthlog-ktext = wa_header-ktext.
wa_zthlog-aenam = sy-uname.
wa_zthlog-aedat = sy-datum.
wa_zthlog-larnt = wa_operation-larnt.
wa_zthlog-pronr = wa_header-pronr.
wa_zthlog-arbei = wa_operation-arbei.
wa_zthlog-dauno = wa_operation-dauno.
wa_zthlog-dauno = wa_operation-dauno.
wa_zthlog-ltxa1 = wa_operation-ltxa1.
wa_zthlog-arbid = wa_operation-arbid.
wa_zthlog-fieldname = 'PRONR'.
wa_zthlog-matkl = wa_operation-matkl.
wa_zthlog-preis = wa_operation-preis.
wa_zthlog-waers = wa_header-waers.
wa_zthlog-old_value = wa_header_old-pronr.
wa_zthlog-new_value = wa_header-pronr.
Fill t_zthlog - Call FM
APPEND wa_zthlog TO t_zthlog.
ENDIF.
ENDLOOP.
Secure Values before change
MOVE t_zthlog TO y_zthlog.+
Calling FM -->
+function z_thlog.
t_zthlog[] = c_zthlog[].
call screen 0100 starting at 10 3.
c_zthlog[] = t_zthlog[].
endfunction.+
ALV Grid - Processing -->
+module output_0100 output.
Fill Fieldcatalog
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZTHLOG'
changing
ct_fieldcat = gt_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if g_custom_container is initial.
Prepare ALV
create object g_custom_container
exporting container_name = g_container.
create object grid1
exporting i_parent = g_custom_container.
g_repid = sy-repid.
gs_layout-grid_title = 'Änderungsprotokoll'.
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_variant-report = g_repid.
gs_variant = '/default'.
gs_layout-edit = 'X'.
Call ALV
call method grid1->set_table_for_first_display
exporting
i_structure_name = 'ZTHLOG'
is_layout = gs_layout
i_save = 'A'
is_variant = gs_variant
changing
it_outtab = t_zthlog
it_fieldcatalog = gt_fieldcat[].
Ready for Input
call method grid1->set_ready_for_input
exporting
i_ready_for_input = 1.
Eventregistration
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
create object g_event_receiver.
set handler g_event_receiver->handle_data_changed for grid1.
else.
Refresh, if filled
call method grid1->refresh_table_display.
endif.
set Cursor
call method cl_gui_control=>set_focus
exporting
control = grid1.
endmodule. " output_0100 OUTPUT+
There are alot of fields so the manual creation of the fieldcatalog should be avoided if possible.
Any Help is appreciated!
Best Regards
StefanHi,
Check this
* Module Pai INPUT *
* PAI module *
module pai input.
save_ok = ok_code.
clear ok_code.
call method grid1->check_changed_data
importing
e_valid = v_valid.
" After this system will automatically update your changed data into
" internal table t_zthlog
case save_ok.
when 'EXIT'.
perform f_exit_program.
when 'CANC'.
perform f_exit_program.
when 'BACK'.
perform f_exit_program.
when 'SAVE'.
perform f_save_data.
endcase.
endmodule. " Pai INPUT
aRs -
How to insert sales text (MM02) into a single record of a Ztable.
Hi,
I'm extracting data from different data base tables and populating a Ztable which has Matnr as primary key and sales text as a field.
I have already used READ_TEXT to display the text and it is displayed in multiple records which in turn leads to duplication of Material numbers.
Now I want to avoid duplication of records (Matnr) as this being a primary record, and display the sales text of a particular material number into one single record.
Can anyone tell me how to insert sales text (MM02) transaction into one single record.
Thanks,
Govindsorry i am not enough clear about your requirement...
as i can understand i am explaining to you.
suppose your itab contains repaeating matnr.
matnr
1
1
2
2
2
3
3
like this.
data : text(200),
matnr like mara-matnr.
loop at itab.
call READ_TEXT fnmodule.
loop at tline.
concatenate text tline-tdline into text.
endloop.
matnr = itab-matnr.
at end of matnr.
itab1-matnr = matnr.
itab1-text = text.
append itab1.
clear text.
endat.
endloop.
NB change the code as per your requirement
regards
shiba dutta -
How can I load a flat file into a ZTABLE dynamically
I need to create a program which can Load a ZTABLE from a flat file structure (delimited and fixed options required). We have many ZTables where this will be required so I was hoping to do it dynamically somehow. Otherwise I will have to create one ABAP for every ZTable we have to load.
My Inputs should be
PARAMETERS: p_ztable TYPE ddobjname, "Z Table Name
p_infile(132) LOWER CASE, "File Name
p_delim(1). "Delimiter
I know that I can read the file by using gui_upload
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = c_infile
has_field_separator = p_delim
TABLES
data_tab = indata
EXCEPTIONS
file_open_error = 1
file_read_error = 2
OTHERS = 9.
I know that I can split the contents of this file (if a delimiter is used). However I will not know the actual field names of the table until runtime as to what to fields to split it into. In the example below I have the actual table (t_rec) and each of the fields (pernr, lgart, etc) in the code but each table I
need to load will be different – it will have a different # of fields as well.
FORM read_data_pc.
LOOP AT indata.
PERFORM splitdata USING indata.
APPEND t_rec.
CLEAR t_rec.
ENDLOOP.
ENDFORM.
FORM splitdata USING p_infile.
SPLIT p_infile AT p_delim INTO
t_rec-pernr "Employee #
t_rec-lgart "Wage Type
t_rec-begda "Effective date
t_rec-endda. "End date
ENDFORM.
Once I split the data into the fields then I can just look and insert the record.
Does anyone have any ideas? Specific code examples would be great if you do. Thx!!Hi janice,,
Try this sample code where you can upload data from a flat file into the internal table.
REPORT z_test.
TABLES: mara.
FIELD-SYMBOLS : <fs> .
DATA : fldname(50) TYPE c.
DATA : col TYPE i.
DATA : cmp LIKE TABLE OF rstrucinfo WITH HEADER LINE.
DATA: progname LIKE sy-repid,
dynnum LIKE sy-dynnr.
DATA itab TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
DATA: BEGIN OF ZUPLOAD1_T OCCURS 0 ,
matnr like mara-matnr,
ersda like mara-ersda,
ernam like mara-ernam,
laeda like mara-laeda,
END OF ZUPLOAD1_T.
*DATA: ZUPLOAD1_T LIKE mara OCCURS 0 WITH HEADER LINE.
DATA: wa_data LIKE TABLE OF ZUPLOAD1_T WITH HEADER LINE.
selection-screen
SELECTION-SCREEN: BEGIN OF BLOCK blk WITH FRAME TITLE text-001.SELECTION-SCREEN : SKIP 1. PARAMETERS : p_file LIKE rlgrap-filename.SELECTION-SCREEN : SKIP 1.SELECTION-SCREEN : END OF BLOCK blk
. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
F4 Value for File
CALL FUNCTION 'KD_GET_FILENAME_ON_F4' EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
static = 'X'
MASK = ' '
CHANGING file_name = p_file EXCEPTIONS mask_too_long = 1 OTHERS = 2
. IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING filename = P_FILE
i_begin_col = 1
i_begin_row = 1
i_end_col = 5
i_end_row = 12507
tables
intern = ITAB
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 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 'GET_COMPONENT_LIST'
EXPORTING
program = SY-REPID
fieldname = 'ZMARA'
tables
components = CMP.
LOOP AT itab. AT NEW row.
IF sy-tabix = 1. APPEND ZUPLOAD1_T.
ENDIF.
ENDAT.
col = itab-col.
READ TABLE cmp INDEX col.
CONCATENATE 'ZUPLOAD1_T-' cmp-compname INTO fldname.
ASSIGN (fldname) TO <fs>.
<fs> = itab-COL.
APPEND ZUPLOAD1_T. ENDLOOP.
DELETE ZUPLOAD1_T where matnr eq space.
LOOP AT ZUPLOAD1_T INTO wa_data.
insert mara from wa_data .
WRITE: / ZUPLOAD1_T-matnr, 20 ZUPLOAD1_T-ersda , 45 ZUPLOAD1_T-ernam, 55 ZUPLOAD1_T-laeda.
*HERE IAM JUST CHECKING I NEED TO UPDATE A ZTABLE
ENDLOOP.
insert ZMARA FROM table itab ACCEPTING DUPLICATE KEYS.
I have tried it for mara.Please let me know whether it was helful.
Regards,
Kannan -
hi ,
i am getting an error message while am creating an append structure.
what i have done is ..
i created a structure in SE11 with 4 fields with name zstruct .
and i have one ztable with 5 fields. when i am trying to append a structure through Append Structure button , system is asking for the name of the structure.
here is my problem...
when trying to giving the structure name which i was created earlier ie., zstruct, it giving error that " structure name is already created."
can any please help me in this regard.
cheers,
srak.hi..
u cannt append the structure with the same name as it is already created.....
u have to give the different name and thier u specify the field names....
the u r table will get appended with the new fields...
hope it works...
thanks
sam -
Error while uploading data to ztable from excel file
Hi,
I have a requirement where i have to upload data from excel file to ztable.I have used the fm 'ALSM_EXCEL_TO_INTERNAL_TABLE' for reading the excel file.After reading the excel file i have used INSERT zrb_hdr from table t_zrb_hdr for updating the ztable with data .
here it is giving error as the data base table zrb_hdr and the internal table t_zrb_hdr should be declared of same type .
I got this error b'coz i have changed the date and time fields in t_zrb_hdr table to char type.so the structure of zrb_hdr and t_zrb_hdr are not same.If i don't change the date and time fields,in the o/p i am not getting proper date and time formats.
now how can i upload data into ztable?Hi,
Try this.
Data: itab type standard table of ztable,
wa_itab type ztable.
loop at t_zrb_hdr into wa_t_zrb_hdr.
wa_itab-date = wa_t_zrb_hdr-date.
wa_itab-time = wa_t_zrb_hdr-time.
like move all the fiedl to wa_itab...........
append itab with wa_itab.
Endloop.
now insert the records from itab to the database table ztable.
Thanks,
Muthu. -
Ztable not updating in sales order user exit
Hi Genius Abapers.
We want to take text ID data of sales order into Ztable. For taking the data we have used user exit in sales order. Now the problem is if we go through debug mode then the Ztable is updating but if we remove the break point Ztable is not getting updated.
Please give solution for this problem
Regards
NarayanaHi Gurus,
I am basically from SD and we used commit statements in the programme and this is the code we used
Include name --- MV45AF0B_BELEG_INITIALISIEREN
**********************************Code Addd by paresh 8.10.2007 starts *******************************
DATA : BEGIN OF itab_so OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
spras LIKE t002t-spras,
END OF itab_so.
DATA : BEGIN OF itab_so1 OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
spras LIKE t002t-spras,
END OF itab_so1.
DATA : BEGIN OF it_tabid OCCURS 0,
tdid LIKE stxh-tdid,
tdspras like stxh-tdspras,
END OF it_tabid.
DATA : is_stxh TYPE stxh.
DATA g_header TYPE string .
DATA wa_plain_text TYPE zplain_text.
DATA t_lines LIKE tline OCCURS 0 WITH HEADER LINE.
DATA g_item(16)." type i.
data :it_ztable type table of ZPLAIN_TEXT .
data wa_ztable type zplain_text.
data flag.
*****************************Read Header text***************************************
*loop at vbak.
itab_so1-vbeln = vbak-vbeln.
itab_so1-posnr = vbak-posnr.
itab_so1-spras = vbak-wklnd.
APPEND itab_so1.
CLEAR itab_so1.
ENDLOOP.
refresh it_tabid.
clear it_tabid.
refresh it_ztable.
clear it_ztable.
LOOP AT xvbap.
itab_so-vbeln = vbak-vbeln.
itab_so-posnr = xvbap-posnr.
itab_so-spras = xvbap-wklnd.
APPEND itab_so.
CLEAR itab_so.
ENDLOOP.
LOOP AT itab_so.
SELECT tdid tdspras FROM stxh INTO TABLE it_tabid WHERE tdobject = 'VBBK' AND tdname = vbak-vbeln .
ENDLOOP.
*loop at it_ztable into wa_ztable.
LOOP AT itab_so.
LOOP AT it_tabid.
is_stxh-tdobject = 'VBBK'.
is_stxh-tdname = vbak-vbeln.
is_stxh-tdid = it_tabid-tdid.
is_stxh-tdspras = it_tabid-tdspras.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = is_stxh-tdid
language = is_stxh-tdspras
name = is_stxh-tdname
object = is_stxh-tdobject
TABLES
lines = t_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc = 0.
LOOP AT t_lines.
CONCATENATE g_header t_lines-tdline INTO g_header SEPARATED BY space.
ENDLOOP.
wa_plain_text-application = 'SO'.
wa_plain_text-key1 = itab_so-vbeln.
wa_plain_text-key1 = vbak-vbeln.
wa_plain_text-key2 = 'HDR'.
wa_plain_text-sub_application = it_tabid-tdid.
wa_plain_text-text = g_header.
wa_plain_text-last_date = sy-datum.
MODIFY zplain_text FROM wa_plain_text .
wait up to 60 seconds.
commit work.
CLEAR: wa_plain_text.
CLEAR : g_header,t_lines.
refresh t_lines.
ENDIF.
if sy-subrc <> 0.
delete from zplain_text where key1 = vbak-vbeln and
key2 = itab_so-posnr and
SUB_APPLICATION = it_tabid-tdid.
commit work.
endif.
ENDLOOP.
ENDLOOP.
*endloop.
Please do me the needfull
Regards
Manam.Narayana -
Data is not showing in R/3 ztable whlie creating XI inbound proxy.
Hi experts,
I am creating an XI inbound proxy for zxx_stockyard_price_ib_dt ,
I created Ztable(this structure contains both filename and data structure) in R/3 and i am writing a code in sproxy to fetch the data from XI to R/3, R/3 is to fill and store the data in a ztabe .
XI data file is ok, however , when executed ,the input file of XI is not reflecting in the R/3 Ztable,
I need a help in this scenario,
here is the peice of code,
METHOD zxx_ii_stockyard_price_ib_mi~stockyard_price_ib_mi.
DATA : it_zxx_stockyard_price_ib_dt TYPE table of zxx_stockyard_price_ib_dt , " input batches from file
wa_zxx_stockyard_price_ib_dt TYPE zxx_stockyard_price_ib_dt ,
i_zrva_trv_interfa TYPE TABLE OF zrva_trv_interfa ,
wa_zrva_trv_interfa TYPE zrva_trv_interfa.
******fill input internal table from XI
wa_zxx_stockyard_price_ib_dt = input-stockyard_price_ib_mt.
*fetch the records from XI.
LOOP AT it_zxx_stockyard_price_ib_dt INTO wa_zxx_stockyard_price_ib_dt. " looping input data of XI nd moving the data to R3.
MOVE-CORRESPONDING wa_zxx_stockyard_price_ib_dt TO wa_zrva_trv_interfa.
APPEND wa_zrva_trv_interfa TO i_zrva_trv_interfa.
Modify zrva_trv_interfa FROM WA_zrva_trv_interfa.
ENDLOOP .
IF NOT i_zrva_trv_interfa IS INITIAL.
LOOP AT i_zrva_trv_interfa INTO wa_zrva_trv_interfa.
MODIFY zrva_trv_interfa FROM wa_zrva_trv_interfa.
CLEAR wa_zrva_trv_interfa.
ENDLOOP.
ENDIF.
FREE i_zrva_trv_interfa.
ENDMETHOD.
when execute and debugged i found the values are not showing in internal table i_zrva_trv_interfa (loop at i_zrva_trv_interfa), where i am going wrong?> here is the peice of code,
>
> METHOD zxx_ii_stockyard_price_ib_mi~stockyard_price_ib_mi.
> DATA : it_zxx_stockyard_price_ib_dt TYPE table of zxx_stockyard_price_ib_dt , " input batches from file
> wa_zxx_stockyard_price_ib_dt TYPE zxx_stockyard_price_ib_dt ,
> i_zrva_trv_interfa TYPE TABLE OF zrva_trv_interfa ,
> wa_zrva_trv_interfa TYPE zrva_trv_interfa.
>
> ******fill input internal table from XI
> wa_zxx_stockyard_price_ib_dt = input-stockyard_price_ib_mt.
>
I think here at this place you have problem. As per your code you have moved the input-stockyard_price_ib_mt to wa_zxx_stockyard_price_ib_dt BUT you have not appended to the internal table it_zxx_stockyard_price_ib_dt.
If I am wrong then make sure it_zxx_stockyard_price_ib_dt is filled correctly before you loop on it.
also add the below check befor looping.
IF NOT it_zxx_stockyard_price_ib_dt is INITIAL.
> *fetch the records from XI.
> LOOP AT it_zxx_stockyard_price_ib_dt INTO wa_zxx_stockyard_price_ib_dt. " looping input data of XI nd moving the data to R3.
> MOVE-CORRESPONDING wa_zxx_stockyard_price_ib_dt TO wa_zrva_trv_interfa.
> APPEND wa_zrva_trv_interfa TO i_zrva_trv_interfa.
> * Modify zrva_trv_interfa FROM WA_zrva_trv_interfa.
> ENDLOOP .
ENDIF. "IF NOT it_zxx_stockyard_price_ib_dt is INITIAL.
>
> IF NOT i_zrva_trv_interfa IS INITIAL.
> LOOP AT i_zrva_trv_interfa INTO wa_zrva_trv_interfa.
> MODIFY zrva_trv_interfa FROM wa_zrva_trv_interfa.
> CLEAR wa_zrva_trv_interfa.
> ENDLOOP.
>
> ENDIF.
>
> FREE i_zrva_trv_interfa.
>
> ENDMETHOD.
>
>
> when execute and debugged i found the values are not showing in internal table i_zrva_trv_interfa (loop at i_zrva_trv_interfa), where i am going wrong?
Regards,
Sarvesh -
Unable to Update data in Ztable (dbase) through Table Control.
Hi Experts.
I am able to pull dta from Ztable into table control and also able to insert a new line and delete a row from table control. But after trying a lot I am unbale to pass the same from Table control to Ztable.
Any ideas. Seems like here Update of Ztable needs some different treatment.
PLZ LOOK into the code in red only. rest are for reference.
The code on the Flow Logic Screen:
PROCESS BEFORE OUTPUT.
module init_100.
LOOP At it_auftrag1 with CONTROL tctrl1 cursor tctrl1-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_auftrag1.
Module modify_it_auftrag1.
ENDLOOP.
MODULE fcode_100.
MODULE USER_COMMAND_9000.
The code on main Screen (Mod. Pool Screen ) follows:
PROGRAM SAPMZDEMO_MPOOL_06.
TABLES: ZLT_Auftrag1, ZLT_Kunde.
DATA: fcode2(4), fcode(4). "OK_Code.
CONTROLS : tctrl1 type TABLEVIEW USING SCREEN '9000'.
DATA: col TYPE cxtab_column.
DATA: demo_cprop, demo_tprop.
DATA: Begin Of it_Auftrag1 occurs 20,
marked.
include structure ZLT_auftrag1.
DATA: END OF it_Auftrag1.
DATA: linno TYPE i.
DATA: fld(20).
DATA: off TYPE i.
module fcode_100 input.
endmodule. " fcode_100 INPUT
module modify_it_auftrag1 input.
modify it_Auftrag1 index tctrl1-current_line.
endmodule. " modify_it_auftrag1 INPUT
module init_100 output.
set pf-status 'ZSTATUS01'.
Describe Table it_auftrag1 lines tctrl1-lines. "TO add Scroll Bar to Table Control1
UPDATE ZLT_Auftrag1 From it_auftrag1.
endmodule. " init_100 OUTPUT
module USER_COMMAND_9000 input.
CASE sy-ucomm.
*To Populate Data into Kunde through Pushbuttons
When 'OK_GETK'.
IF ZLT_Kunde-K1 is NOT INITIAL.
SELECT SINGLE *
FROM ZLT_Kunde
Where K1 = ZLT_KUNDE-K1.
IF ZLT_Kunde-K1 is NOT initial.
Select *
From ZLT_Auftrag1
INTO Corresponding fields of TABLE it_auftrag1
Where A3 = ZLT_Kunde-K2.
ENDIF.
ELSE.
MESSAGE S000(8i) With 'Enter Kunde Name'.
ENDIF.
when 'DELL'.
* remove marked lines
delete it_auftrag1.
loop at it_auftrag1 where marked = 'X'.
UPDATE ZLT_Auftrag1 From it_auftrag1.
endloop.
if sy-subrc <> 0.
get cursor field fld line linno offset off.
set cursor field fld line linno offset off.
if fld cp 'IT_auftrag1*' and sy-subrc = 0.
linno = linno + tctrl1-top_line - 1.
delete it_auftrag1 index linno.
tctrl1-lines = tctrl1-lines - 1.
endif.
endif.
When 'INSL'.
* insert line above cursor position
get cursor field fld line linno offset off.
set cursor field fld line linno offset off.
if fld cp 'IT_auftrag1*' and sy-subrc = 0.
if linno >= 1.
linno = linno + tctrl1-top_line - 1.
clear it_auftrag1.
insert it_auftrag1 index linno.
tctrl1-lines = tctrl1-lines + 1.
else.
clear it_auftrag1.
append it_auftrag1.
tctrl1-lines = tctrl1-lines + 1.
endif.
endif.
When 'SAVE'.
loop at it_auftrag1 where marked = 'X'.
* Modify it_Auftrag1.
Modify ZLT_Auftrag1 From it_Auftrag1.
Endloop.
IF sy-subrc = 0.
MESSAGE s000(8i) With 'Data Saved'.
ENDIF.
When 'BACK'.
Leave Program.
When 'OK_CLEAR'.
Clear : ZLT_KUNDE, ZLT_AUFTRAG1, it_auftrag1.
ENDCASE.
endmodule. " USER_COMMAND_9000 INPUT
Looking forward for your advice,
Regards
ChandanHi Venkat,
Thanks again. I will try ur suggestion too. In the meanwhile I did the following changes in the code:
Purpose: After data is getting pulled from dbase table (ZLT_Auftrag1) into internal table it_auftrag1 then and just after I press the button delete ( i.e. When the user command starts: When 'DELL' )
then I delete all the contents reflecting in it_auftrag1 from ZLT_Auftrag1, Now the Ztable is empty but it_auftrag1 holds all values. futher when loop starts then the Marked line gets deleted. Now at this stage the it_Auftrag1 contains all data of ZLT_auftrag1 except the line that I want to delete. If I am able to MODIFY the ZLT_auftrag1 from it_Auftrag1 at this stage then ZLT_Auftrag1 will again be populated with all those data except the line that I want to delete.
Here goes the code that I modified ( ref the code in my 1st post in red to compare)
WHEN 'DELL'.
* remove marked lines
* If it_Auftrag1-Marked = 'X'.
DELETE from ZLT_Auftrag1 where A3 = ZLT_kunde-K2.
* ENDIF.
IF sy-subrc = 0.
loop at it_auftrag1 where marked = 'X'.
DELETE it_auftrag1.
* INSERT ZLT_Auftrag1 From TABLE it_auftrag1 accepting duplicate keys.
* UPDATE ZLt_auftrag1 from TABLE it_auftrag1.
* MODIFY ZLT_Auftrag1 From TABLE it_auftrag1.
endloop.
* INSERT ZLT_Auftrag1 From TABLE it_auftrag1.
* UPDATE ZLt_auftrag1 from TABLE it_auftrag1.
* MODIFY ZLT_Auftrag1 From TABLE it_auftrag1.
* If sy-subrc = 0.
* MESSAGE S000(8i) With 'Data Deleted from Database'.
* ENDIF.
ENDIF.
MODIFY ZLT_Auftrag1 from it_Auftrag1. ==> This modification doesn't works.
If sy-subrc = 0.
MESSAGE S000(8i) With 'Data Deleted from Database'.
ENDIF.
if sy-subrc <> 0.
get cursor field fld line linno offset off.
set cursor field fld line linno offset off.
if fld cp 'IT_auftrag1*' and sy-subrc = 0.
linno = linno + tctrl1-top_line - 1.
delete it_auftrag1 index linno.
tctrl1-lines = tctrl1-lines - 1.
endif.
endif.
Looking forward for your suggestions.
Regards
Chandan
Maybe you are looking for
-
How to expand a PDF text box?
I have created a PDF exporting the document from word and made it into a form to fill out. When I have created a text box I would like it to expand when there is more words than there is space rather than the text box going into scrolling mode and no
-
Help! I can't get rid of this little black box!
I ordered DSL service and tried to hook it up the other day, unsuccessfully. In the instructions it says that if you have problems to insert the disk provided. I told the lady I ordered from that I had a Mac and she said it would be no problem, but o
-
I recently began using reminders in ical and downloaded the iPhone and iPad app. It works great. However, the reminders in ical on the COMPUTER is difficult to work with - thin long column on the right rather than in it's own screen. is there a remin
-
5/06/2014 - Beta - Flash Player 14.0.0.95
The latest Flash Player 14 builds are now available. You can download Flash Player here: http://www.adobe.com/go/flashplayerbeta. New Features for Flash Player 14: PPAPI Content Debugger We're pleased to announce the immediate availability of the PP
-
Custom AP_WEB_EXPENSE_CUST_WF
Has anyone customized the DOCUSTOMVALIDATION function in the AP_WEB_EXPENSE_CUST_WF package? I created a custom table to hold "Expense Policies". When an expense report is submitted I want to check each line amount on the ap_expense_report_lines_all