Populating a Forum froma data grid in Flex
I have a forum that I would like to pouplate to be able to edit the information in Flex (flash builder four). So how would I click on a row of data (from a datagrid) and have it populate the forum?
Hi,
Do you mean a Form? Try listening for the "gridClick" event on the DataGrid and looking at the "item" property of the event. This event dispatches when the user clicks on the DataGrid and item will be the data object from the row that the user clicks on. I've written up a simple example below:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout gap="10" paddingTop="10" paddingRight="10" />
</s:layout>
<fx:Script>
<![CDATA[
import spark.events.GridEvent;
protected function dataGrid_gridClickHandler(event:GridEvent):void
var item:Object = event.item;
if (item)
keyTI.text = item.key;
nameTI.text = item.name;
]]>
</fx:Script>
<s:DataGrid id="dataGrid" gridClick="dataGrid_gridClickHandler(event)">
<s:ArrayCollection>
<fx:Object key="1000" name="Abrasive" />
<fx:Object key="1001" name="Brush"/>
<fx:Object key="1002" name="Clamp"/>
<fx:Object key="1003" name="Drill"/>
<fx:Object key="1004" name="Epoxy"/>
<fx:Object key="1005" name="File" />
<fx:Object key="1006" name="Gouge"/>
<fx:Object key="1007" name="Hook"/>
<fx:Object key="1008" name="Ink" />
<fx:Object key="1009" name="Jack" />
</s:ArrayCollection>
</s:DataGrid>
<s:Form>
<s:FormItem label="key">
<s:TextInput id="keyTI" />
</s:FormItem>
<s:FormItem label="name">
<s:TextInput id="nameTI" />
</s:FormItem>
</s:Form>
</s:Application>
Of course, you'll have to write some code so that the you can edit the data and save it from the Form. Hope this helps.
-Kevin
Similar Messages
-
Automatically populating a Form from data stored in Access
Hi,
I need help automatically populating a form from data stored in Access. The form needs to have specific fields that are updated from an Access database. I want to be able to enter a site number and have the subsequent list of information (approximately 35 pieces of data) populate. I DO NOT want to update the Access database via the form. The form is for quick viewing and documentation only, not data entry. Currently I've been doing this with VB in Access which exported the data to a Word Document which was then saved as a PDF. It seems easier and less troublesome to go directly to the PDF form, but I can't figure out how!
I have already connected my database to the form using OLEDB.
I don't want a dropdown list and I don't want buttons to scroll through the sites (I've already found out how to do that through this forum).
Any help would be very much appreciated!!Some more help to get started in this.. would be really appreciated..Are you trying to come up with the graphs yourself? IF so, are you familiar with MVC?
-
"advanced data grid" with flex builder 3.0
I'm getting watermark as "Flex Data Visualization
Trial" when tried to use advances data grid with flex builder 3.0. There are some links floating on the internet where it's suggested that the license key should be provided in the flex-config.xml to avoid this issue. I would like to know if this componenet is stable with flex builder 3.0 and is it ok to use this in production environment?Someone from Adobe might be able to answer more definitely
but it's probably just not considered compatible with a modified
Eclipse (at least, the installer). It may just be the installer
blowing up when it shouldn't. I think Adobe doesn't want to support
install configurations that they don't have setup and tested. I had
a similar issue once and solved it by doing the following... not
sure if it'll work, and it's more of a last resort:
Setup a regular eclipse install - install the plugin there.
Somehow, you'll have to keep track of all the files it adds, either
using timestamps or some compare software. It should be a bunch of
files and/or folders in the '/plugins' directory, and possibly a
few others in '/configuration', maybe '/features'. Take all the new
folders and any jar files etc, and drop them into the same folders
in your special Eclipse version. Hopefully when you start it up
you'll get the Flex functions...
Of course, you could end up hosing your entire "NWDS"
(whatever this is) install. So you probably want to test it out
first! -
How to put an image in a data grid in Flex Builder 2
Hi All,
I need to populate a data grid with some text data received
from a web service and, in a particular column of the datagrid, I
have to put an image depending of a specific data returned me by
the web service.
It seems that there is the possibility to add an image in
data grid column with the cellRenderer properties, but this
property is available only for ActionScript 3.
I'm developing an application in Flex Builder 2 that run
ActionScript 2 and cellRenderer properties is not available. Is it
right?
If no, I will can use this cellRenderer properties in my
application. Please, can you show me an example?
If yes, there is a way to insert an image in datagridcolumn
with ActionScript 2?
Thank you very much
RegardsFlex Builder 2 uses Actionscript 3.
You will need to write a renderer for for this column.
There are a lot of examples of datagrids with images in them.
here is one from the livedocs
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=cellrenderer_072_28.html -
Value from data grid not showing in workspace
Hi everyone.
I've entered value in data grid that i maid in Planning for one member. It looks like there is no velue for that member. What needs to be done to recognize new source?
Member is set on Store and is used in some formulas in Dynamic Calc members.
Thx.Maybe it is an implied share, is it is an only child, set the member to "never share", refresh and try again.
Cheers
John
http://john-goodwin.blogspot.com/ -
Custom pegging component for data grid in flex
A pegging component useful when you want to display a limited amount of data in datagrid.
<code>
<pagging:Pagging id="pagging" size="15" ui="{dataGridRef}" dp="{data}" />
</code>Flex Builder 2 uses Actionscript 3.
You will need to write a renderer for for this column.
There are a lot of examples of datagrids with images in them.
here is one from the livedocs
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=cellrenderer_072_28.html -
How To Populate An Advanced Data Grid In Flex With An XML Document Created In JAVA
Flex Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="856" height="698" initialize="onInitData()">
<mx:RemoteObject destination="utilityUCFlexRO" id="utilityUCFlexRO">
<mx:method name="updateStationDetails" result="handleUpdateStationDetailsResult(event)" fault="handleUpdateStationDetailsFault(event)"/>
</mx:RemoteObject>
<mx:RemoteObject id="uniqueIdMasterUCFlexRO" destination="uniqueIdMasterUCFlexRO">
<mx:method name="readByCustomerName" result="handleReadByCustomerNameResult(event)" fault="handleReadByCustomerNameFault(event)"/>
<mx:method name="getCustomerAcDetails" result="handlegetCustomerAcDetailsResult(event)" fault="handlegetCustomerAcDetailsFault(event)"/>
</mx:RemoteObject>
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.collections.ItemResponder;
import com.citizen.cbs.model.UniqueIdMaster;
import mx.managers.PopUpManager;
import mx.controls.ProgressBarMode;
import mx.effects.Fade;
import mx.controls.ProgressBar;
import com.citizen.cbs.CitizenApplication;
import mx.core.Application;
import mx.messaging.messages.ErrorMessage;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
private var moduleCloseFlag:Boolean=false;
private var v:UniqueIdMaster;
[Bindable]
private var customerDetails:ArrayCollection;
[Bindable]
private var branch:int=0;
[Bindable]
private var XMLDocument:XML;
[Bindable]
private var acDetails:XMLList;
private var _progBar:ProgressBar = new ProgressBar();
private function showLoading(e:Event = null):void
_progBar.width = 200;
_progBar.indeterminate = true;
_progBar.labelPlacement = 'center';
_progBar.setStyle("removedEffect", Fade);
_progBar.setStyle("addedEffect", Fade);
_progBar.setStyle("color", 0xFFFFFF);
_progBar.setStyle("borderColor", 0x000000);
_progBar.setStyle("barColor", 0x6699cc);
_progBar.label = "Please wait.......";
_progBar.mode = ProgressBarMode.MANUAL;
PopUpManager.addPopUp(_progBar,this,true);
PopUpManager.centerPopUp(_progBar);
_progBar.setProgress(0, 0);
private function onInitData():void
utilityUCFlexRO.updateStationDetails(CitizenApplication.menuParameters["modulecode"]);
private function handleUpdateStationDetailsResult(event:ResultEvent):void
if(moduleCloseFlag==true)
Application.application.unloadModule();
private function handleUpdateStationDetailsFault(event:FaultEvent):void
var errorMessage:ErrorMessage = event.message as ErrorMessage;
Alert.show(errorMessage.rootCause.message);
private function onSearch():void
if(txtName.text=="" || txtName.text==null)
Alert.show("Enter a name for search");
return;
if((txtName.text).length < 4)
Alert.show("Search should contain more than 3 alphabets");
return;
var d:String = txtName.text;
branch = CitizenApplication.initInfo.registeredUser.branchDetails.bdBranchNo;
uniqueIdMasterUCFlexRO.readByCustomerName(d,branch);
showLoading();
private function handleReadByCustomerNameResult(event:ResultEvent):void //In handle if record does not exists, dsiplays error message and resets the field
customerDetails =ArrayCollection(event.result);
PopUpManager.removePopUp(_progBar);
if(customerDetails.length==0)
Alert.show("Record Not Found, Enter Proper Name ");
onReset();
private function handleReadByCustomerNameFault(event:FaultEvent):void
Alert.show(event.fault.faultDetail + " -- " + event.fault.faultString + "handleReadByCustomerNameFault");
private function onReset():void
customerDetails=new ArrayCollection();
txtName.text="";
private function onCancel():void
utilityUCFlexRO.updateStationDetails("MM0001");
moduleCloseFlag=true;
private function btnBackClick():void
view1.selectedIndex=0;
private function btnBackClick1():void
view1.selectedIndex=1;
private function onItemClick( e:ListEvent ):void
if(dgCustDetails.selectedItem == null)
Alert.show("Select Proper Record");
else
lblId.text = e.itemRenderer.data.uimCustomerId;
lblName.text = e.itemRenderer.data.uimCustomerName;
var custId:int = Number(lblId.text);
uniqueIdMasterUCFlexRO.getCustomerAcDetails(custId,branch);
showLoading();
private function handlegetCustomerAcDetailsResult(event:ResultEvent):void
//XMLDocument = event.result as XML;
acDetails = new XMLList(event.result.menu);
//Alert.show("Name: "+event.result.@name);
PopUpManager.removePopUp(_progBar);
view1.selectedIndex=1;
//adg1.dataProvider=acDetails;
private function handlegetCustomerAcDetailsFault(event:FaultEvent):void
PopUpManager.removePopUp(_progBar);
Alert.show(event.fault.faultDetail + " -- " + event.fault.faultString + "handlegetCustomerAcDetailsFault");
]]>
</mx:Script>
<mx:ViewStack height="688" width="856" id="view1">
<mx:Canvas>
<mx:Panel x="51" y="25" width="754" height="550" layout="absolute" title="Customer Search Page">
<mx:HBox x="174" y="26" horizontalAlign="center" verticalAlign="middle">
<mx:Label text="Enter Name:"/>
<mx:TextInput id="txtName" width="228"/>
<mx:LinkButton label="Search" click="onSearch()"/>
</mx:HBox>
<mx:Label text="--" id="lblId" x="40" y="194"/>
<mx:Label text="--" id="lblName" x="40" y="226"/>
<mx:DataGrid dataProvider="{customerDetails}" id="dgCustDetails" allowMultipleSelection="false" editable="false"
showHeaders="true" draggableColumns="false" width="718" height="373" itemClick="onItemClick(event);" x="10" y="61">
<mx:columns>
<mx:DataGridColumn headerText="Customer Id" dataField="uimCustomerId" width="150"/>
<mx:DataGridColumn headerText="Customer Name" dataField="uimCustomerName"/>
</mx:columns>
</mx:DataGrid>
<mx:ControlBar>
<mx:Button label="CANCEL" click="onCancel()" width="80"/>
<mx:Button label="RESET" click="onReset()" width="80"/>
</mx:ControlBar>
</mx:Panel>
</mx:Canvas>
<mx:Canvas>
<mx:TitleWindow x="10" y="10" width="836" height="421" layout="absolute">
<mx:AdvancedDataGrid x="6.5" y="10" id="adg1" designViewDataType="tree" variableRowHeight="true" width="807" height="278" fontSize="14">
<mx:dataProvider>
<mx:HierarchicalData source="{acDetails}"/>
</mx:dataProvider>
<mx:groupedColumns>
<mx:AdvancedDataGridColumn headerText="Type Of A/c" dataField="@Name" width="150"/>
<mx:AdvancedDataGridColumn headerText="Details Of A/c"/>
</mx:groupedColumns>
<mx:rendererProviders>
<mx:AdvancedDataGridRendererProvider id="adgpr1" depth="2" columnIndex="1" renderer="AcDetails1" columnSpan="0"/>
</mx:rendererProviders>
</mx:AdvancedDataGrid>
<mx:ControlBar height="56" y="335">
<mx:Button label="BACK" width="80" click="btnBackClick()"/>
<mx:Spacer width="100%"/>
<mx:Button label="EXIT" click="onCancel()" width="80"/>
</mx:ControlBar>
</mx:TitleWindow>
</mx:Canvas>
</mx:ViewStack>
</mx:Module>
XML File Generated In JAVA:
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<AcType Name="Savings">
<SavingAcDetails AcName="Mr. MELROY BENT" AccountNo="4" ClearBalance="744.18" ProductID="SB" TotalBalance="744.18">
<SavingMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="AnyOne Single Or Survivor"/>
</SavingAcDetails>
</AcType>
<AcType Name="TermDeposit">
<TDAcDetails AcName="Mr. BENT MELROY" AccountNo="1731" ProductID="TD">
<TDMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Either or Survivor"/>
</TDAcDetails>
<TDAcDetails AcName="Mr. BENT MELROY" AccountNo="2287" ProductID="TD">
<TDMoreAcDetails AcStatus="NEW" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Self"/>
</TDAcDetails>
<TDAcDetails AcName="Mr. BENT MELROY" AccountNo="78" ProductID="TD">
<TDMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Self"/>
</TDAcDetails>
</AcType>
</menu>
Tried Alot Of Examples Online But In Vain....
Need Help....
Thanks In Advance....Please help me !!!! I have been stuck up with this issue for the past two days and I need to atleast figure out if this is possible or not in the first place.
-
How to create PDF from data grid selected row records and save in local PC
ok now i am need another help ;
i am having one datagrid and one button outside the grid ,
i am having one datagrid in that i am having 5 records if i click a record from the datagrid then click that button means that particular record will save as PDF in my local PC.
How to do that,
Any suggession or examples.
Thanks in advance
B.venkatesan.<cfdocument>
Usage is described in the cfml reference manual. If you don't have one, the internet does. -
Hello,
I have to display into a data grid, in Flex 2, 2 columns:
first column ( "Images") must contain a picture with an object and
second column (" quantity") must contain the amount of that object
that I want to buy. The problem is that I must take the name of the
image from an .xml file, specified like this:
<mx:DataGrid id="obj" dataProvider="{ObjList}" > where
ObjList is the .xml file with <name/>
<picture_address/> etc.
The second column must contain a textbox so I can input a
number of items for each picture ( can be also a combobox where
from I can select some value, from 1 to 20 for example).
I've searched the Internet and I haven't found a solution
yet. Please give me a link or a solution for this problem.
Tudoruse itemrenderes.... the example below shows how to add an
image.... you can do the same thing with a text box or combo box
<mx:DataGridColumn width="10" headerText="Image">
<mx:itemRenderer>
<mx:Component>
<mx:Canvas width="100%" height="100%">
<mx:Image verticalCenter="0" horizontalCenter="0"
source="{data.picture_adress}""/>
</mx:Canvas>
</mx:Component>
</mx:itemRenderer> -
Hi there,
I am a beginner in Visual Basic Express 2010. I have a Point of Sale program that uses DataGridView to display records from an external microsoft access
database using the fillby query.
It works, but it repopulates the same row each time, but i want to be able to display multiple records at the same time, a new row should be filled for
each click of the fillby button.
also I want to be able to delete any records if the customer suddenly decides to not buy an item after it has already been entered.
so actually 2 questions here:
1. how to populate a new row for each click of the fillby button
2. how to delete records from data grid view after an item has been entered
Thanks
VishwasHello,
The FillBy method loads data according to what the results are from the SELECT statement, so if there is one row then you get one row in the DataGridView, have two rows then two rows show up.
Some examples
Form load populates our dataset with all data as it was defined with a plain SELECT statement. Button1 loads via a query I created after the fact to filter on a column, the next button adds a new row to the existing data. When adding a new row it is appended
to the current data displayed and the primary key is a negative value but the new key is shown after pressing the save button on the BindingNavigator or there are other ways to get the new key by manually adding the row to the backend table bypassing the Adapter.
The following article with code shows this but does not address adapters.
Conceptually speaking the code in the second code block shows how to get the new key
Public Class Form1
Private Sub StudentsBindingNavigatorSaveItem_Click(
sender As Object, e As EventArgs) Handles StudentsBindingNavigatorSaveItem.Click
Me.Validate()
Me.StudentsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MyDataSet)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MyDataSet.Students' table. You can move, or remove it, as needed.
Me.StudentsTableAdapter.Fill(Me.MyDataSet.Students)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.StudentsTableAdapter.FillBy(Me.MyDataSet.Students, ComboBox1.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.MyDataSet.Students.AddStudentsRow("Jane", "Adams", "Female")
End Sub
End Class
Get new key taken from
this article.
Public Function AddNewRow(ByVal sender As Customer, ByRef Identfier As Integer) As Boolean
Dim Success As Boolean = True
Try
Using cn As New OleDb.OleDbConnection With {.ConnectionString = Builder.ConnectionString}
Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
cmd.CommandText = InsertStatement
cmd.Parameters.AddWithValue("@CompanyName", sender.CompanyName)
cmd.Parameters.AddWithValue("@ContactName", sender.ContactName)
cmd.Parameters.AddWithValue("@ContactTitle", sender.ContactTitle)
cn.Open()
cmd.ExecuteNonQuery()
cmd.CommandText = "Select @@Identity"
Identfier = CInt(cmd.ExecuteScalar)
End Using
End Using
Catch ex As Exception
Success = False
End Try
Return Success
End Function
In closing I have not given you a solution but hopefully given you some stuff/logic to assist with this issue, if not perhaps I missed what you want conceptually speaking.
Additional resources
http://msdn.microsoft.com/en-us/library/fxsa23t6.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
Difference between Data Grid and Data Forms
Hi all,
What is the difference between data grid and data forms.Data entry forms are pre defined and are generally used to manually input data into reporting (financial statement) schedules.
They can also be used for reviewing purposes and it gives users a presentable / and consistent format to view data in Hyperion.
Data grids are the equivalent of pivot tables in excel. It should be used for ad hoc purposes to view / analyse data in whatever form you choose. The user has the flexibility to choose what they see in the rows, columns and page dimensions.
One of the main differences between data entry forms and data grids is that you can’t export data grids to excel whereas you can with data entry forms. Other differences are:
1. Run consolidation, translation, promotion from data grids but not in data entry forms.
2. You can link other data entry forms to a data entry form
3. Data entry forms offer greater formatting options than in data grids i.e. colours, fonts, bold, italics.
At the end of the day, they are similar and there is no reason why you can’t have (use) both. It all depends on your local needs on how best you use both.
I hope above information helps. -
Pulling Data from an imported web service into a data grid - Flex 3.0
Hi all,
I have created a web service from Oracle using JDeveloper and imported it into my Fex 3 project, and I am trying to populate a data grid with the data from the web service. I was trying to emulate the example found in my Adobe Flex 3.0 for Dummies book (see http://dougmccune.com/flexfordummies/chapter14/srcview/index.html), and while the code from the book with that data service works fine, I can't get my application to work. My issue is with the part of code mx:DataGrid dataProvider="(service)" - I do not know how to specify what to use for the data source to populate the data grid from my imported web service. Any suggestions or examples would be helpful, as I am a newcomer to Adobe Flex. My code is as follows:
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"xmlns:webservices="
generated.webservices.*">
<mx:Script>
<![CDATA[
private function getData():void {service.getPdRec(ageDt.text);
]]>
</mx:Script>
<webservices:PD_Pct_Web_Service id="service" />
<mx:VBox>
<mx:HBox width="100%">
<mx:TextInput id="ageDt" width="100%" />
<mx:Button id="submitButton" label="Search" click="getData()" />
</mx:HBox>
<mx:DataGrid dataProvider="(service.getPdRec_lastResult
" rowHeight="
58" width="100%" height="300">
<mx:columns>
<mx:DataGridColumn dataField="creditManager" headerText="Credit Manager" width="40" />
<mx:DataGridColumn dataField="pdTarget" headerText="PD Target" width="40" />
<mx:DataGridColumn dataField="totalPd" headerText="Total PD" width="40" />
<mx:DataGridColumn dataField="pdPct" headerText="PD Percent" width="50" />
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Application>
My web service returns the following when invoked:
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://erec_db/PD_Pct_Web_Service.wsdl/types/">
<env:Body>
<ns0:getPdRecResponseElement>
<ns0:result>
<ns0:creditManager>Cobb</ns0:creditManager>
<ns0:pdTarget>10</ns0:pdTarget>
<ns0:totalPd>147.65</ns0:totalPd>
<ns0:pdPct>26.77</ns0:pdPct>
</ns0:result>
<ns0:result>
<ns0:creditManager>Collova</ns0:creditManager>
<ns0:pdTarget>10</ns0:pdTarget>
<ns0:totalPd>27.71</ns0:totalPd>
<ns0:pdPct>21.67</ns0:pdPct>
</ns0:result>
<ns0:result>
<ns0:creditManager>Lee</ns0:creditManager>
<ns0:pdTarget>10</ns0:pdTarget>
<ns0:totalPd>33.61</ns0:totalPd>
<ns0:pdPct>72.38</ns0:pdPct>
</ns0:result>
<ns0:result>
<ns0:creditManager>Maynard</ns0:creditManager>
<ns0:pdTarget>10</ns0:pdTarget>
<ns0:totalPd>74.19</ns0:totalPd>
<ns0:pdPct>33.69</ns0:pdPct>
</ns0:result>
<ns0:result>
<ns0:creditManager>Ong</ns0:creditManager>
<ns0:pdTarget>10</ns0:pdTarget>
<ns0:totalPd>13.26</ns0:totalPd>
<ns0:pdPct>46.06</ns0:pdPct>
</ns0:result>
</ns0:getPdRecResponseElement>
</env:Body>
</env:Envelope>Use data binding. <mx:DataGrid dataProvider="{service.getPdRec_lastResult}"
-Radhakrishna -
How to move a selected row data from one grid to another grid using button click handler in flex4
hi friends,
i am doing flex4 mxml web application,
i am struck in this concept please help some one.
i am using two seperated forms and each form having one data grid.
In first datagrid i am having 5 rows and one button(outside the data grid with lable MOVE). when i am click a row from the datagrid and click the MOVE button means that row should disable from the present datagrid and that row will go and visible in the second datagrid.
i dont want drag and drop method, i want this process only using button click handler.
how to do this?
any suggession or snippet code are welcome.
Thanks,
B.venkatesan.Hi,
You can get an idea from foolowing code and also from the link which i am providing.
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="613" height="502" viewSourceURL="../files/DataGridExampleCinco.mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.binding.utils.BindingUtils;
[Bindable]
private var allGames:ArrayCollection;
[Bindable]
private var selectedGames:ArrayCollection;
private function initDGAllGames():void
allGames = new ArrayCollection();
allGames.addItem({name: "World of Warcraft",
creator: "Blizzard", publisher: "Blizzard"});
allGames.addItem({name: "Halo",
creator: "Bungie", publisher: "Microsoft"});
allGames.addItem({name: "Gears of War",
creator: "Epic", publisher: "Microsoft"});
allGames.addItem({name: "City of Heroes",
creator: "Cryptic Studios", publisher: "NCSoft"});
allGames.addItem({name: "Doom",
creator: "id Software", publisher: "id Software"});
protected function button1_clickHandler(event:MouseEvent):void
BindingUtils.bindProperty(dgSelectedGames,"dataProvider" ,dgAllGames ,"selectedItems");
]]>
</mx:Script>
<mx:Label x="11" y="67" text="All our data"/>
<mx:Label x="10" y="353" text="Selected Data"/>
<mx:Form x="144" y="10" height="277">
<mx:DataGrid id="dgAllGames" width="417" height="173"
creationComplete="{initDGAllGames()}" dataProvider="{allGames}" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="Game Name" dataField="name" width="115"/>
<mx:DataGridColumn headerText="Creator" dataField="creator"/>
<mx:DataGridColumn headerText="Publisher" dataField="publisher"/>
</mx:columns>
</mx:DataGrid>
<mx:FormItem label="Label">
<mx:Button label="Move" click="button1_clickHandler(event)"/>
</mx:FormItem>
</mx:Form>
<mx:Form x="120" y="333">
<mx:DataGrid id="dgSelectedGames" width="417" height="110" >
<mx:columns>
<mx:DataGridColumn headerText="Game Name" dataField="name" width="115"/>
<mx:DataGridColumn headerText="Creator" dataField="creator"/>
<mx:DataGridColumn headerText="Publisher" dataField="publisher"/>
</mx:columns>
</mx:DataGrid>
</mx:Form>
</mx:Application>
Link:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/ae9bee8d-e2ac-43 c5-9b6d-c799d4abb2a3/
Thanks and Regards,
Vibhuti Gosavi | [email protected] | www.infocepts.com -
Getting data back from ALV grid
This looks like a topic discussed before but i still need some clearifications. I display an internal table in ALV grid, in editable format. user changes the data and presses A BUTTON. On doing that I need to re-capture the changes made in a internal table.
I have used method "check_changed_data' but it doesnt seem to work. It keeps appending data in the internal table if the user changes it multiple times. please suggest me some ideas on how to go about it.
Thanks.
shivHi then i will give another code with OO that fits your requirement check...
REPORT ZTEST NO STANDARD PAGE HEADING
LINE-SIZE 200
LINE-COUNT 58
MESSAGE-ID ZZ.
* Include for Data Declarations
INCLUDE ZSDR0057_DEL_HOLD_TOP.
INCLUDE <ICON>.
**Tables to Compare Before after the Data Change
DATA: IT_VEKP_TMP LIKE IT_VEKP OCCURS 0 WITH HEADER LINE,
IT_VEKP1 LIKE IT_VEKP OCCURS 0 WITH HEADER LINE,
IT_VEKP1_TMP LIKE IT_VEKP OCCURS 0 WITH HEADER LINE,
IT_FINAL_TMP LIKE IT_FINAL OCCURS 0 WITH HEADER LINE,
IT_OCRC TYPE TABLE OF ZSD_OC_HOLD.
DATA: L_VALID TYPE C,
L_VALID1 TYPE C,
V_FLAG,
V_DATA_CHANGE.
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
* CLASS lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
**Hot spot Handler
HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
**User Command Handler
HANDLE_USER_COMMAND FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM,
**Double Click Handler
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN,
**Handler to Check the Data Change
HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,
HANDLE_TOOLBAR
FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT E_INTERACTIVE.
ENDCLASS. "lcl_event_handler DEFINITION
* CLASS lcl_event_handler DEFINITION for second screen
CLASS LCL_EVENT_HANDLER1 DEFINITION .
PUBLIC SECTION .
METHODS:
**User Command Handler
HANDLE_USER_COMMAND FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM,
HANDLE_TOOLBAR
FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT E_INTERACTIVE.
ENDCLASS. "lcl_event_handler1 DEFINITION
* CLASS lcl_event_handler IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Handle Hotspot Click
METHOD HANDLE_HOTSPOT_CLICK .
PERFORM HANDLE_HOTSPOT_CLICK USING E_ROW_ID E_COLUMN_ID ES_ROW_NO .
ENDMETHOD. "lcl_event_handler
*Handle User Command
METHOD HANDLE_USER_COMMAND.
PERFORM EVENT_UCOMM USING E_UCOMM.
ENDMETHOD. "user_command
*Handle Double Click
METHOD HANDLE_DOUBLE_CLICK.
DATA X_FINAL TYPE T_FINAL.
IF V_DATA_CHANGE IS INITIAL.
IF E_COLUMN = 'ZZPROMDT' OR E_COLUMN = 'ZZOCHOLDRC'.
READ TABLE IT_FINAL INDEX E_ROW INTO X_FINAL
TRANSPORTING
VBELN
VGBEL
VGPOS
ZZPROMDT
ZZOCHOLDRC.
IF SY-SUBRC = 0.
PERFORM GET_HU_DATA USING X_FINAL.
PERFORM POPULATE_FIELDCAT2.
ENDIF.
CALL SCREEN 200.
ENDIF.
ELSE.
MESSAGE I002 WITH 'Please save the data first and then double click'.
ENDIF.
ENDMETHOD. "handle_double_click
**Handle Data Change
METHOD HANDLE_DATA_CHANGED.
DATA: X_CHANGE TYPE LVC_S_MODI,
X_FINAL TYPE T_FINAL,
X_OCRC TYPE ZSD_OC_HOLD,
L_FLAG.
LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
IF X_CHANGE-FIELDNAME = 'ZZOCHOLDRC'.
READ TABLE IT_FINAL INTO X_FINAL INDEX X_CHANGE-ROW_ID.
IF SY-SUBRC = 0.
READ TABLE IT_OCRC INTO X_OCRC WITH KEY
ZZOCHOLDRC = X_CHANGE-VALUE
TRANSPORTING ZZRCDESC.
IF SY-SUBRC = 0.
X_FINAL-ZZRCDESC = X_OCRC-ZZRCDESC.
MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID
TRANSPORTING ZZRCDESC.
L_FLAG = 'X'.
ENDIF.
ENDIF.
ENDIF.
IF X_CHANGE-FIELDNAME = 'ZZPROMDT'.
READ TABLE IT_FINAL INTO X_FINAL INDEX X_CHANGE-ROW_ID.
IF SY-SUBRC = 0.
X_FINAL-ZZPROMDT = X_CHANGE-VALUE.
MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID
TRANSPORTING ZZPROMDT.
L_FLAG = 'X'.
ENDIF.
ENDIF.
ENDLOOP.
IF L_FLAG = 'X'.
CLEAR V_DATA_CHANGE.
V_DATA_CHANGE = 'X'.
ENDIF.
ENDMETHOD. "data_changed
METHOD HANDLE_TOOLBAR.
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 SAVE icon
CLEAR LS_TOOLBAR.
MOVE 'SAVE' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_SYSTEM_SAVE TO LS_TOOLBAR-ICON.
MOVE 'Save' TO LS_TOOLBAR-QUICKINFO.
MOVE ' Save ' TO LS_TOOLBAR-TEXT.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR LS_TOOLBAR.
* 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 BACK icon
CLEAR LS_TOOLBAR.
MOVE 'BACK' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_SYSTEM_BACK TO LS_TOOLBAR-ICON.
MOVE 'Back' TO LS_TOOLBAR-QUICKINFO.
MOVE ' Back ' TO LS_TOOLBAR-TEXT.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR LS_TOOLBAR.
ENDMETHOD. "handle_toolbar
ENDCLASS. "lcl_event_handler IMPLEMENTATION
* CLASS lcl_event_handler1 IMPLEMENTATION
CLASS LCL_EVENT_HANDLER1 IMPLEMENTATION.
*Handle User Command
METHOD HANDLE_USER_COMMAND.
PERFORM EVENT_UCOMM1 USING E_UCOMM.
ENDMETHOD. "user_command
METHOD HANDLE_TOOLBAR.
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 SAVE icon
CLEAR LS_TOOLBAR.
MOVE 'SAVE' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_SYSTEM_SAVE TO LS_TOOLBAR-ICON.
MOVE 'Save' TO LS_TOOLBAR-QUICKINFO.
MOVE ' Save ' TO LS_TOOLBAR-TEXT.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR LS_TOOLBAR.
* 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 Back icon
CLEAR LS_TOOLBAR.
MOVE 'BACK' TO LS_TOOLBAR-FUNCTION.
MOVE ICON_SYSTEM_BACK TO LS_TOOLBAR-ICON.
MOVE 'Back' TO LS_TOOLBAR-QUICKINFO.
MOVE ' Back ' TO LS_TOOLBAR-TEXT.
MOVE ' ' TO LS_TOOLBAR-DISABLED.
APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR LS_TOOLBAR.
ENDMETHOD. "handle_toolbar
ENDCLASS. "lcl_event_handler1 IMPLEMENTATION
*& Global Definitions
DATA: "G_GRID TYPE REF TO CL_GUI_ALV_GRID, "Grid for first report
G_GRID1 TYPE REF TO CL_GUI_ALV_GRID, "grid for second report
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
G_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"container
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER, "handler
G_HANDLER1 TYPE REF TO LCL_EVENT_HANDLER1. "handler
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER1 TYPE SCRFNAME VALUE 'ZSDR0057_DEL_HOLD_CONT1',
G_CONTAINER2 TYPE SCRFNAME VALUE 'ZSDR0057_DEL_HOLD_CONT2',
GS_LAYOUT TYPE LVC_S_LAYO,
GS_LAYOUT1 TYPE LVC_S_LAYO.
*- Fieldcatalog for First and second Report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
X_FIELDCAT TYPE LVC_S_FCAT,
IT_FIELDCAT1 TYPE LVC_T_FCAT,
X_FIELDCAT1 TYPE LVC_S_FCAT,
LS_VARI TYPE DISVARIANT.
* Selection screen
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR V_LIKP-VBELN, "Delivery
S_VSTEL FOR V_LIKP-VSTEL, "Shipping Point
S_WERKS FOR V_LIPS-WERKS, "Plant
S_WADAT FOR V_VBEP-WADAT, "Pgi Date
S_TRSPG FOR V_LIKP-TRSPG OBLIGATORY,"Shp bolck Reason
S_OCHRC FOR V_VEKP-ZZOCHOLDRC MATCHCODE OBJECT
ZZOCHOLDRC, "OC Reason Code
S_USERID FOR V_VBAK-ZZREP_USERID1."Rep User ID
SELECTION-SCREEN END OF BLOCK B1.
* START-OF_SELECTION
START-OF-SELECTION.
CLEAR IT_LIKP.
REFRESH IT_LIKP.
SELECT VBELN
VSTEL
LFDAT
KUNNR
FROM LIKP
INTO TABLE IT_LIKP
WHERE VBELN IN S_VBELN
AND VSTEL IN S_VSTEL
AND WADAT IN S_WADAT
AND WADAT_IST = '00000000'
AND TRSPG IN S_TRSPG.
IF SY-SUBRC <> 0.
CLEAR V_FLAG.
V_FLAG = 'X'.
ENDIF.
IF V_FLAG = ' '.
**Populating the Delivery Item Data
PERFORM GET_DEL_ITEM_DATA.
**Getting the PGI DATE & USERID
PERFORM GET_USERID.
**Getting the Promise DATE & OC HOLD RC
PERFORM GET_VEKP_DATA.
**get the Reason codes
PERFORM SELECT_OCHOLDRC.
IF NOT IT_LIPS[] IS INITIAL
AND NOT IT_VBAK[] IS INITIAL
AND NOT IT_VEKP_TMP[] IS INITIAL.
** Populating the Final Internaltable
PERFORM POPULATE_FINAL_TABLE.
ENDIF.
ENDIF.
* END-OF-SELECTION.
END-OF-SELECTION.
IF NOT IT_FINAL[] IS INITIAL.
CALL SCREEN 100. "Calling the First Screen
ELSE.
MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
ENDIF.
* MODULE PBO OUTPUT *
MODULE PBO OUTPUT.
DATA: LS_EDIT TYPE LVC_S_STYL, "to find the edit in output
LT_EDIT TYPE LVC_T_STYL, "to find the edit in output
V_INDEX LIKE SY-TABIX,
LS_OUTTAB TYPE T_FINAL.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
**Initializing the grid and calling the fm to Display the O/P
PERFORM CREATE_AND_INIT_ALV.
ENDIF.
ENDMODULE. "PBO OUTPUT
* MODULE PAI INPUT *
MODULE PAI INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE. "pai INPUT
*& Form GET_DEL_ITEM_DATA
* Populating the Delivery Item Data
FORM GET_DEL_ITEM_DATA .
IF NOT IT_LIKP[] IS INITIAL.
**-Getting the name of Ship-to-party
SELECT KUNNR
NAME1
INTO TABLE IT_KNA1
FROM KNA1
FOR ALL ENTRIES IN IT_LIKP[]
WHERE KUNNR = IT_LIKP-KUNNR.
**-Getting Delivery Item Data
SELECT VBELN
POSNR
MATNR
WERKS
ARKTX
VGBEL
VGPOS
ZZCONPATH
INTO TABLE IT_LIPS
FROM LIPS
FOR ALL ENTRIES IN IT_LIKP[]
WHERE VBELN = IT_LIKP-VBELN
AND WERKS IN S_WERKS.
ENDIF.
ENDFORM. " GET_DEL_ITEM_DATA
*& Form get_userid
* Getting the USERID
FORM GET_USERID .
IF NOT IT_LIPS[] IS INITIAL.
**-Getting the USERID
SELECT VBELN
ZZREP_USERID1
INTO TABLE IT_VBAK
FROM VBAK
FOR ALL ENTRIES IN IT_LIPS[]
WHERE VBELN = IT_LIPS-VGBEL
AND ZZREP_USERID1 IN S_USERID.
ENDIF.
ENDFORM. " get_userid
*& Form populate_final_table
* Populating the Final Internaltable
FORM POPULATE_FINAL_TABLE .
DATA: L_TABIX LIKE SY-TABIX.
CLEAR IT_FINAL.
REFRESH IT_FINAL.
SORT IT_VEKP_TMP BY ZZPROMDT ZZSONUM ZZOCHOLDRC.
DATA IT_TMP LIKE IT_VEKP OCCURS 0 WITH HEADER LINE.
DATA IT_VEKP_TMP1 LIKE IT_VEKP OCCURS 0 WITH HEADER LINE.
CLEAR IT_VEKP_TMP1[].
IT_VEKP_TMP1[] = IT_VEKP_TMP[].
LOOP AT IT_VEKP_TMP.
MOVE IT_VEKP_TMP TO IT_TMP.
CLEAR IT_TMP-EXIDV.
COLLECT IT_TMP.
ENDLOOP.
CLEAR IT_VEKP_TMP[].
IT_VEKP_TMP[] = IT_TMP[] .
LOOP AT IT_VEKP_TMP.
L_TABIX = SY-TABIX.
READ TABLE IT_VEKP_TMP1 WITH KEY INHALT = IT_VEKP_TMP-INHALT
ZZSONUM = IT_VEKP_TMP-ZZSONUM
ZZPROMDT = IT_VEKP_TMP-ZZPROMDT
ZZOCHOLDRC = IT_VEKP_TMP-ZZOCHOLDRC
VEMNG = IT_VEKP_TMP-VEMNG.
IF SY-SUBRC = 0.
IT_VEKP_TMP-EXIDV = IT_VEKP_TMP1-EXIDV.
MODIFY IT_VEKP_TMP INDEX L_TABIX.
ENDIF.
ENDLOOP.
LOOP AT IT_LIPS.
MOVE-CORRESPONDING IT_LIPS TO IT_FINAL.
READ TABLE IT_LIKP WITH KEY VBELN = IT_LIPS-VBELN.
IF SY-SUBRC = 0.
IT_FINAL-VSTEL = IT_LIKP-VSTEL.
IT_FINAL-LFDAT = IT_LIKP-LFDAT.
ENDIF.
READ TABLE IT_KNA1 WITH KEY KUNNR = IT_LIKP-KUNNR.
IF SY-SUBRC = 0.
IT_FINAL-NAME1 = IT_KNA1-NAME1.
ENDIF.
READ TABLE IT_VBAK WITH KEY VBELN = IT_LIPS-VGBEL.
IF SY-SUBRC = 0.
IT_FINAL-ZZREP_USERID1 = IT_VBAK-ZZREP_USERID1.
ENDIF.
READ TABLE IT_SONUM WITH KEY VGBEL = IT_LIPS-VGBEL
VGPOS = IT_LIPS-VGPOS.
IF SY-SUBRC = 0.
LOOP AT IT_VEKP_TMP WHERE ZZSONUM = IT_SONUM-ZZSONUM
AND INHALT = IT_LIPS-VBELN.
IF NOT IT_VEKP_TMP-ZZPROMDT+0(4) = '0000'.
IT_FINAL-ZZPROMDT = IT_VEKP_TMP-ZZPROMDT.
ELSE.
IT_FINAL-ZZPROMDT = '00000000'.
ENDIF.
IT_FINAL-ZZOCHOLDRC = IT_VEKP_TMP-ZZOCHOLDRC.
IT_FINAL-VEMNG = IT_VEKP_TMP-VEMNG.
IT_FINAL-ZZSONUM = IT_VEKP_TMP-ZZSONUM.
IT_FINAL-EXIDV = IT_VEKP_TMP-EXIDV.
APPEND IT_FINAL.
ENDLOOP.
IF SY-SUBRC <> 0.
IT_FINAL-ZZPROMDT = '00000000'.
IT_FINAL-ZZOCHOLDRC = ' '.
IT_FINAL-VEMNG = ' '.
IT_FINAL-FLAG = 'X'.
APPEND IT_FINAL.
CLEAR IT_FINAL.
ENDIF.
ENDIF.
ENDLOOP.
DELETE IT_FINAL WHERE ZZOCHOLDRC NOT IN S_OCHRC[].
DELETE IT_FINAL WHERE ZZREP_USERID1 NOT IN S_USERID[].
DELETE IT_FINAL WHERE WERKS NOT IN S_WERKS[].
IF NOT IT_ZSDOCHOLD[] IS INITIAL.
LOOP AT IT_FINAL.
READ TABLE IT_ZSDOCHOLD WITH KEY ZZOCHOLDRC = IT_FINAL-ZZOCHOLDRC.
IF SY-SUBRC = 0.
IT_FINAL-ZZRCDESC = IT_ZSDOCHOLD-ZZRCDESC.
MODIFY IT_FINAL.
ENDIF.
ENDLOOP.
ENDIF.
IT_FINAL_TMP[] = IT_FINAL[].
CLEAR IT_FINAL.
ENDFORM. " populate_final_table
*& Form get_vekp_data
* Populating Promise Date and Order Control Hold Reason Code
FORM GET_VEKP_DATA .
CLEAR: IT_SONUM,IT_VEKP,IT_VEKP_TMP.
REFRESH: IT_SONUM,IT_VEKP,IT_VEKP_TMP.
LOOP AT IT_LIPS.
MOVE-CORRESPONDING IT_LIPS TO IT_SONUM.
CONCATENATE IT_LIPS-VGBEL IT_LIPS-VGPOS INTO IT_SONUM-ZZSONUM.
APPEND IT_SONUM.
CLEAR IT_SONUM.
ENDLOOP.
IF NOT IT_SONUM[] IS INITIAL.
SELECT EXIDV
INHALT
ZZSONUM
ZZPROMDT
ZZOCHOLDRC
INTO TABLE IT_VEKP
FROM VEKP
FOR ALL ENTRIES IN IT_SONUM[]
WHERE ZZSONUM = IT_SONUM-ZZSONUM
AND ZZOCHOLDRC IN S_OCHRC.
SELECT EXIDV INHALT VEMNG
ZZSONUM
INTO TABLE IT_QUANT
FROM ZVEKPO
FOR ALL ENTRIES IN IT_SONUM[]
WHERE ZZSONUM = IT_SONUM-ZZSONUM.
IF SY-SUBRC = 0.
LOOP AT IT_VEKP.
READ TABLE IT_QUANT WITH KEY EXIDV = IT_VEKP-EXIDV
INHALT = IT_VEKP-INHALT
ZZSONUM = IT_VEKP-ZZSONUM.
IF SY-SUBRC = 0.
IT_VEKP-VEMNG = IT_QUANT-VEMNG.
MODIFY IT_VEKP.
ENDIF.
ENDLOOP.
IT_VEKP_TMP[] = IT_VEKP[].
SELECT ZZOCHOLDRC
ZZRCDESC
INTO TABLE IT_ZSDOCHOLD
FROM ZSD_OC_HOLD
FOR ALL ENTRIES IN IT_VEKP[]
WHERE ZZOCHOLDRC = IT_VEKP-ZZOCHOLDRC.
ENDIF.
ENDIF.
ENDFORM. " get_vekp_data
*& Form SELECT_OCHOLDRC
* Selecting the Reason Codes and Descriptions
FORM SELECT_OCHOLDRC .
SELECT *
FROM ZSD_OC_HOLD
INTO TABLE IT_OCRC.
ENDFORM. " select_OCHOLDRC
*& Form CREATE_AND_INIT_ALV
* Creating the ALV grid and initializing
FORM CREATE_AND_INIT_ALV .
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER1.
CREATE OBJECT G_GRID
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
* Set a titlebar for the grid control
GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.
GS_LAYOUT-GRID_TITLE = TEXT-003.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_ROWMARK = 'X'.
GS_LAYOUT-ZEBRA = SPACE."'X'.
GS_LAYOUT-INFO_FNAME = SPACE.
GS_LAYOUT-CTAB_FNAME = SPACE.
CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_USER_COMMAND FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_TOOLBAR FOR G_GRID.
* setting focus for created grid control
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = G_GRID.
* Build fieldcat and set editable for date and reason code
* edit enabled. Assign a handle for the dropdown listbox.
PERFORM BUILD_FIELDCAT.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
PERFORM DISABLE_EDIT_FIELDS.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = SPACE.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
* Define a drop down table.
PERFORM SET_DRDN_TABLE.
**Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = LS_VARI
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = IT_FIELDCAT
IT_OUTTAB = IT_FINAL[].
* Set editable cells to ready for input initially
CALL METHOD G_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
CALL METHOD G_GRID->SET_TOOLBAR_INTERACTIVE.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* Excluding the ALV functions
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_fieldcat
* Fieldcatalog
FORM BUILD_FIELDCAT .
DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Shpt'(012).
X_FIELDCAT-FIELDNAME = 'VSTEL'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '4'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Con Path'(013).
X_FIELDCAT-FIELDNAME = 'ZZCONPATH'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '8'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Plant'(014).
X_FIELDCAT-FIELDNAME = 'WERKS'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Del Date'(015).
X_FIELDCAT-FIELDNAME = 'LFDAT'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-COLTEXT = 'Prom Date'(016).
* X_FIELDCAT-SCRTEXT_M = 'Prom Date'(016).
X_FIELDCAT-FIELDNAME = 'ZZPROMDT'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-EDIT = 'X'.
* X_FIELDCAT-HOTSPOT = 'X'.
X_FIELDCAT-DATATYPE = 'DATS'.
X_FIELDCAT-INTTYPE = 'D'.
X_FIELDCAT-REF_TABLE = 'VEKP'.
X_FIELDCAT-REF_FIELD = 'ZZPROMDT'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Ship-To-Name'(017).
X_FIELDCAT-FIELDNAME = 'NAME1'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '40'.
X_FIELDCAT-EMPHASIZE = ' '.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'SalesOrder#'(018).
X_FIELDCAT-FIELDNAME = 'VGBEL'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Item'(019).
X_FIELDCAT-FIELDNAME = 'VGPOS'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-OUTPUTLEN = '5'.
X_FIELDCAT-HOTSPOT = ' '.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Material'(020).
X_FIELDCAT-FIELDNAME = 'MATNR'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '18'.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-HOTSPOT = ' '.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Materal Desc'(021).
X_FIELDCAT-FIELDNAME = 'ARKTX'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '40'.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-HOTSPOT = ' '.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'D.O.Item Qty'(022).
X_FIELDCAT-FIELDNAME = 'VEMNG'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '13'.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-HOTSPOT = ' '.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'RC'(023).
X_FIELDCAT-FIELDNAME = 'ZZOCHOLDRC'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '3'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-DRDN_HNDL = '1'.
X_FIELDCAT-DRDN_ALIAS = 'X'.
* X_FIELDCAT-DRDN_FIELD = 'DROP_DOWN_HANDLE'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
* X_FIELDCAT-SCRTEXT_M = 'OC HOLD RC Desc'.
* X_FIELDCAT-FIELDNAME = 'ZZRCDESC'.
* X_FIELDCAT-TABNAME = 'IT_FINAL'.
* X_FIELDCAT-COL_POS = L_POS.
* X_FIELDCAT-OUTPUTLEN = '20'.
* X_FIELDCAT-EDIT = 'X'.
* X_FIELDCAT-HOTSPOT = ' '.
* APPEND X_FIELDCAT TO IT_FIELDCAT.
* CLEAR X_FIELDCAT.
* L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Item'(025).
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
X_FIELDCAT-EMPHASIZE = ' '.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Rep User Id'(026).
X_FIELDCAT-FIELDNAME = 'ZZREP_USERID1'.
X_FIELDCAT-TABNAME = 'IT_FINAL'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '11'.
X_FIELDCAT-EMPHASIZE = ' '.
X_FIELDCAT-HOTSPOT = ' '.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
ENDFORM. " build_fieldcat
*& Form set_drdn_table
* Setting the Drop down for the Reason code
FORM SET_DRDN_TABLE.
DATA: X_OCRC LIKE LINE OF IT_OCRC.
DATA:LT_DRAL TYPE LVC_T_DRAL,
LS_DRAL TYPE LVC_S_DRAL,
L_DRDN(25) TYPE C.
LOOP AT IT_OCRC INTO X_OCRC.
CONCATENATE X_OCRC-ZZOCHOLDRC ' ' ' ' ' ' X_OCRC-ZZRCDESC INTO L_DRDN
SEPARATED BY SPACE.
* First listbox (handle '1').
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = L_DRDN.
LS_DRAL-INT_VALUE = X_OCRC-ZZOCHOLDRC.
APPEND LS_DRAL TO LT_DRAL.
ENDLOOP.
**Setting the Drop down table for Reason Code
CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
EXPORTING
IT_DROP_DOWN_ALIAS = LT_DRAL.
ENDFORM. " set_drdn_table
*& Form handle_hotspot_click
* Handling the Hotspot
FORM HANDLE_HOTSPOT_CLICK USING I_ROW_ID TYPE LVC_S_ROW
I_COLUMN_ID TYPE LVC_S_COL
IS_ROW_NO TYPE LVC_S_ROID.
READ TABLE IT_FINAL INDEX I_ROW_ID .
IF SY-SUBRC = 0.
IF I_COLUMN_ID-FIELDNAME = 'VGBEL'.
PERFORM FORM_REFRESH.
SET PARAMETER ID 'AUN' FIELD IT_FINAL-VGBEL.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
**if user clicks on Delivery
IF I_COLUMN_ID-FIELDNAME = 'VBELN'.
PERFORM FORM_REFRESH.
SET PARAMETER ID 'VL' FIELD IT_FINAL-VBELN.
CALL TRANSACTION 'VL02N' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDFORM . "handle_hotspot_click
*& Form FORM_REFRESH for first list
FORM FORM_REFRESH .
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
EXCEPTIONS
FINISHED = 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.
ENDFORM . "FORM_REFRESH
*& Form event_ucomm
* Handling User Commands
FORM EVENT_UCOMM USING E_UCOMM TYPE SY-UCOMM.
SORT IT_FINAL.
SORT IT_FINAL_TMP.
CASE E_UCOMM.
WHEN 'BACK'.
CALL METHOD G_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID.
CALL METHOD CL_GUI_CFW=>FLUSH.
PERFORM BACK_OPERATION.
WHEN 'SAVE'.
CALL METHOD G_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID.
CALL METHOD CL_GUI_CFW=>FLUSH.
PERFORM SAVE_OPERATION.
ENDCASE.
ENDFORM. " event_ucomm
*& Form back_operation
* When User do Back operation
FORM BACK_OPERATION .
**When User Press back Button
* WHEN 'BACK'.
DATA: L_ANS TYPE C,
L_TABIX TYPE SY-TABIX,
L_SONUM TYPE VEKP-ZZSONUM,
X_OCRC LIKE LINE OF IT_OCRC.
**Checking for the Data Change
IF IT_FINAL_TMP[] <> IT_FINAL[].
PERFORM CONFIRM_BEFORE_LEAVE CHANGING L_ANS.
IF L_ANS = '1' .
LOOP AT IT_FINAL.
L_TABIX = SY-TABIX.
READ TABLE IT_FINAL_TMP INDEX L_TABIX.
IF SY-SUBRC = 0.
IF IT_FINAL <> IT_FINAL_TMP.
*-Validate Date Field.
PERFORM VALIDATE_AND_CONVERT_DATE.
**Modifying the VEKP table based on changes
IF NOT IT_FINAL_TMP-EXIDV IS INITIAL.
UPDATE VEKP SET ZZOCHOLDRC = IT_FINAL-ZZOCHOLDRC
ZZPROMDT = IT_FINAL-ZZPROMDT
WHERE EXIDV = IT_FINAL_TMP-EXIDV
AND INHALT = IT_FINAL-VBELN.
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT.
ENDIF.
ELSE.
UPDATE VEKP SET ZZOCHOLDRC = IT_FINAL-ZZOCHOLDRC
ZZPROMDT = IT_FINAL-ZZPROMDT
WHERE INHALT = IT_FINAL-VBELN
AND ZZSONUM = IT_FINAL_TMP-ZZSONUM
AND ZZPROMDT = IT_FINAL_TMP-ZZPROMDT
AND ZZOCHOLDRC = IT_FINAL_TMP-ZZOCHOLDRC.
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
LEAVE TO SCREEN 0.
ELSEIF L_ANS = '2'.
LEAVE TO SCREEN 0.
ENDIF.
ELSE.
LEAVE TO SCREEN 0.
ENDIF.
ENDFORM. " back_operation
*& Form CONFIRM_BEFORE_LEAVE
* Popup for Confirm
FORM CONFIRM_BEFORE_LEAVE CHANGING P_ANS TYPE C.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Confirm'(007)
TEXT_QUESTION = 'Do you wish to save your data first?'(006)
TEXT_BUTTON_1 = 'Yes'(008)
ICON_BUTTON_1 = 'ICON_OKAY'
TEXT_BUTTON_2 = 'No'(010)
ICON_BUTTON_2 = 'ICON_CANCEL'
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
START_COLUMN = 25
START_ROW = 6
IMPORTING
ANSWER = P_ANS
EXCEPTIONS
TEXT_NOT_FOUND = 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.
ENDFORM. " CONFIRM_BEFORE_LEAVE
*& Form VALIDATE_AND_CONVERT_DATE
* Validating and Converting the date
FORM VALIDATE_AND_CONVERT_DATE .
DATA : L_DATE LIKE SY-DATUM.
CALL FUNCTION 'CONVERT_DATE_INPUT'
EXPORTING
INPUT = IT_FINAL-ZZPROMDT
IMPORTING
OUTPUT = L_DATE
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
WRONG_FORMAT_IN_INPUT = 2
OTHERS = 3.
IF SY-SUBRC = 0.
WRITE L_DATE TO IT_FINAL-ZZPROMDT.
MODIFY IT_FINAL.
ENDIF.
ENDFORM. " VALIDATE_AND_CONVERT_DATE
*& Module STATUS_0200 OUTPUT
* PBO of Second List
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER1 IS INITIAL.
**Initializing the second Grid
PERFORM CREATE_AND_INIT_ALV1.
ENDIF.
ENDMODULE. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
* PAI of Second list
MODULE USER_COMMAND_0200 INPUT.
DATA: L_ANS.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CANC'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*& Form CREATE_AND_INIT_ALV1
* Creating the Grid for Second List
FORM CREATE_AND_INIT_ALV1 .
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
CREATE OBJECT G_CUSTOM_CONTAINER1
EXPORTING CONTAINER_NAME = G_CONTAINER2.
CREATE OBJECT G_GRID1
EXPORTING I_PARENT = G_CUSTOM_CONTAINER1.
CALL METHOD G_GRID1->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
CREATE OBJECT G_HANDLER1.
SET HANDLER G_HANDLER1->HANDLE_USER_COMMAND FOR G_GRID1.
SET HANDLER G_HANDLER1->HANDLE_TOOLBAR FOR G_GRID1.
GS_LAYOUT1-GRID_TITLE = TEXT-003.
GS_LAYOUT1-CWIDTH_OPT = 'X'.
GS_LAYOUT1-NO_ROWMARK = 'X'.
GS_LAYOUT1-ZEBRA = SPACE."'X'.
GS_LAYOUT1-INFO_FNAME = SPACE.
GS_LAYOUT1-CTAB_FNAME = SPACE.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = SPACE.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
* setting focus for created grid control
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = G_GRID1.
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
* Define a drop down table.
PERFORM SET_DRDN_TABLE1.
PERFORM FORM_REFRESH.
CALL METHOD G_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = LS_VARI
I_SAVE = 'A'
IS_LAYOUT = GS_LAYOUT1
CHANGING
IT_FIELDCATALOG = IT_FIELDCAT1
IT_OUTTAB = IT_VEKP1[].
** Set editable cells to ready for input initially
CALL METHOD G_GRID1->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
CALL METHOD G_GRID1->SET_TOOLBAR_INTERACTIVE.
ENDFORM. "CREATE_AND_INIT_ALV1
*& Form GET_HU_DATA
* Get Handling Units Data
FORM GET_HU_DATA USING X_FINAL TYPE T_FINAL.
CLEAR IT_VEKP1.
REFRESH IT_VEKP1.
READ TABLE IT_SONUM WITH KEY VGBEL = X_FINAL-VGBEL
VGPOS = X_FINAL-VGPOS.
IF SY-SUBRC = 0.
LOOP AT IT_VEKP WHERE INHALT = X_FINAL-VBELN
AND ZZSONUM = IT_SONUM-ZZSONUM
AND ZZPROMDT = X_FINAL-ZZPROMDT
AND ZZOCHOLDRC = X_FINAL-ZZOCHOLDRC.
IT_VEKP1-EXIDV = IT_VEKP-EXIDV.
IT_VEKP1-ZZSONUM = IT_VEKP-ZZSONUM.
IF NOT IT_VEKP-ZZPROMDT+0(4) = '0000'.
IT_VEKP1-ZZPROMDT = IT_VEKP-ZZPROMDT.
ELSE.
IT_VEKP1-ZZPROMDT = '00000000'.
ENDIF.
IT_VEKP1-ZZOCHOLDRC = IT_VEKP-ZZOCHOLDRC.
APPEND IT_VEKP1.
ENDLOOP.
ENDIF.
IT_VEKP1_TMP[] = IT_VEKP1[].
ENDFORM. " GET_HU_DATA
*& Form POPULATE_FIELDCAT2
* Populating the Field Catalog for Second list
FORM POPULATE_FIELDCAT2 .
CLEAR: IT_FIELDCAT1,X_FIELDCAT1.
REFRESH IT_FIELDCAT1.
DATA:L_POS TYPE I VALUE 1.
CLEAR: L_POS.
L_POS = L_POS + 1.
X_FIELDCAT1-SCRTEXT_M = 'External Handling Unit Identification'(027).
X_FIELDCAT1-FIELDNAME = 'EXIDV'.
X_FIELDCAT1-TABNAME = 'IT_VEKP1'.
X_FIELDCAT1-COL_POS = L_POS.
X_FIELDCAT1-EDIT = ' '.
APPEND X_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR X_FIELDCAT1.
L_POS = L_POS + 1.
* X_FIELDCAT1-SCRTEXT_M = 'Prom Date'(016).
X_FIELDCAT1-COLTEXT = 'Promise Date'(033).
X_FIELDCAT1-FIELDNAME = 'ZZPROMDT'.
X_FIELDCAT1-TABNAME = 'IT_VEKP1'.
X_FIELDCAT1-COL_POS = L_POS.
X_FIELDCAT1-OUTPUTLEN = '12'.
X_FIELDCAT1-EMPHASIZE = ' '.
X_FIELDCAT1-EDIT = 'X'.
X_FIELDCAT1-DATATYPE = 'DATS'.
X_FIELDCAT1-INTTYPE = 'D'.
X_FIELDCAT1-REF_TABLE = 'VEKP'.
X_FIELDCAT1-REF_FIELD = 'ZZPROMDT'.
APPEND X_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR X_FIELDCAT1.
L_POS = L_POS + 1.
X_FIELDCAT1-SCRTEXT_M = 'Order Control Hold Reason Code'(029).
X_FIELDCAT1-FIELDNAME = 'ZZOCHOLDRC'.
X_FIELDCAT1-TABNAME = 'IT_VEKP1'.
X_FIELDCAT1-COL_POS = L_POS.
X_FIELDCAT1-DRDN_HNDL = '1'.
X_FIELDCAT1-DRDN_ALIAS = 'X'.
X_FIELDCAT1-EDIT = 'X'.
APPEND X_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR X_FIELDCAT1.
ENDFORM. " POPULATE_FIELDCAT2
*& Form set_drdn_table
* Drop Down for second report
FORM SET_DRDN_TABLE1.
DATA:X_OCRC LIKE LINE OF IT_OCRC.
DATA:LT_DRAL TYPE LVC_T_DRAL,
LS_DRAL TYPE LVC_S_DRAL,
L_DRDN(25) TYPE C.
LOOP AT IT_OCRC INTO X_OCRC.
CONCATENATE X_OCRC-ZZOCHOLDRC ' ' ' ' ' ' X_OCRC-ZZRCDESC INTO
L_DRDN
SEPARATED BY SPACE.
* First listbox (handle '1').
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = L_DRDN.
LS_DRAL-INT_VALUE = X_OCRC-ZZOCHOLDRC.
APPEND LS_DRAL TO LT_DRAL.
ENDLOOP.
CALL METHOD G_GRID1->SET_DROP_DOWN_TABLE
EXPORTING
IT_DROP_DOWN_ALIAS = LT_DRAL.
ENDFORM. " set_drdn_table
*& Form save_operation
* Saving the changes
FORM SAVE_OPERATION .
DATA: L_TABIX LIKE SY-TABIX.
**CHECKING FOR THE DATA CHANGE
IF IT_FINAL_TMP[] <> IT_FINAL[].
LOOP AT IT_FINAL.
L_TABIX = SY-TABIX.
READ TABLE IT_FINAL_TMP INDEX L_TABIX.
IF SY-SUBRC = 0.
IF IT_FINAL <> IT_FINAL_TMP.
*-Validate Date Field.
PERFORM VALIDATE_AND_CONVERT_DATE.
**Modifying the VEKP table based on changes
IF NOT IT_FINAL_TMP-EXIDV IS INITIAL.
UPDATE VEKP SET ZZOCHOLDRC = IT_FINAL-ZZOCHOLDRC
ZZPROMDT = IT_FINAL-ZZPROMDT
WHERE EXIDV = IT_FINAL_TMP-EXIDV
AND INHALT = IT_FINAL-VBELN.
IF SY-SUBRC = 0.
V_DATA_CHANGE = ' '.
COMMIT WORK AND WAIT.
ENDIF.
ELSE.
UPDATE VEKP SET ZZOCHOLDRC = IT_FINAL-ZZOCHOLDRC
ZZPROMDT = IT_FINAL-ZZPROMDT
WHERE INHALT = IT_FINAL-VBELN
AND ZZSONUM = IT_FINAL_TMP-ZZSONUM
AND ZZPROMDT = IT_FINAL_TMP-ZZPROMDT
AND ZZOCHOLDRC = IT_FINAL_TMP-ZZOCHOLDRC.
IF SY-SUBRC = 0.
V_DATA_CHANGE = ' '.
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM GET_VEKP_DATA .
PERFORM POPULATE_FINAL_TABLE.
PERFORM DISABLE_EDIT_FIELDS.
PERFORM FORM_REFRESH.
MESSAGE S002 WITH 'Data Saved'(011).
ENDIF.
ENDFORM. " save_operation
*& Form BACK_SECOND_LIST
* When User Press Back in Second list
FORM BACK_SECOND_LIST .
DATA:X_OCRC LIKE LINE OF IT_OCRC.
**Checking for the Change in the data
IF IT_VEKP1_TMP[] <> IT_VEKP1[].
PERFORM CONFIRM_BEFORE_LEAVE CHANGING L_ANS.
IF L_ANS = '1'.
LOOP AT IT_VEKP1.
READ TABLE IT_VEKP1_TMP WITH KEY EXIDV = IT_VEKP1-EXIDV.
IF SY-SUBRC = 0.
IF IT_VEKP1_TMP <> IT_VEKP1.
UPDATE VEKP SET ZZPROMDT = IT_VEKP1-ZZPROMDT
ZZOCHOLDRC = IT_VEKP1-ZZOCHOLDRC
WHERE EXIDV = IT_VEKP1-EXIDV.
IF SY-SUBRC = 0.
COMMIT WORK.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM GET_VEKP_DATA .
CLEAR IT_VEKP1_TMP.
REFRESH IT_VEKP1_TMP.
IT_VEKP1_TMP[] = IT_VEKP1[].
PERFORM POPULATE_FINAL_TABLE.
PERFORM DISABLE_EDIT_FIELDS.
PERFORM FORM_REFRESH.
MESSAGE S002 WITH 'Data Saved'(011).
PERFORM CLEAR_GRID_CONTAINER.
ELSEIF L_ANS = '2'.
PERFORM CLEAR_GRID_CONTAINER.
ENDIF.
ELSE.
PERFORM CLEAR_GRID_CONTAINER.
ENDIF.
ENDFORM. " BACK_SECOND_LIST
*& Form clear_grid_container
* Clearing the Grid
FORM CLEAR_GRID_CONTAINER .
CALL METHOD G_GRID1->FREE.
CALL METHOD G_CUSTOM_CONTAINER1->FREE.
CALL METHOD CL_GUI_CFW=>FLUSH.
CLEAR G_CUSTOM_CONTAINER1.
CLEAR G_GRID1.
CLEAR G_HANDLER1.
LEAVE TO SCREEN 0.
ENDFORM. " clear_grid_container
*& Form disable_edit_fields
* Disable edit fields
FORM DISABLE_EDIT_FIELDS .
**Changing the Edit option for the records which they don't have
**Entries in HU level
LOOP AT IT_FINAL INTO LS_OUTTAB WHERE FLAG = 'X'.
V_INDEX = SY-TABIX.
LS_EDIT-FIELDNAME = 'ZZOCHOLDRC'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
LS_EDIT-FIELDNAME = 'ZZRCDESC'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
LS_EDIT-FIELDNAME = 'ZZPROMDT'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY IT_FINAL INDEX V_INDEX FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE DROP_DOWN_HANDLE.
MODIFY IT_FINAL_TMP INDEX V_INDEX FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE DROP_DOWN_HANDLE.
ENDLOOP.
ENDFORM. " disable_edit_fields
*& Form event_ucomm
* Handling User Commands
FORM EVENT_UCOMM1 USING E_UCOMM TYPE SY-UCOMM.
SORT IT_VEKP1.
SORT IT_VEKP1_TMP.
CASE E_UCOMM.
WHEN'BACK'.
**Checking for the change in the data of the output
CALL METHOD G_GRID1->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID1.
CALL METHOD CL_GUI_CFW=>FLUSH.
PERFORM BACK_SECOND_LIST.
WHEN 'SAVE'.
CALL METHOD G_GRID1->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID1.
CALL METHOD CL_GUI_CFW=>FLUSH.
**Checking for the Change in the data
IF IT_VEKP1_TMP[] <> IT_VEKP1[].
LOOP AT IT_VEKP1.
READ TABLE IT_VEKP1_TMP WITH KEY EXIDV = IT_VEKP1-EXIDV.
IF SY-SUBRC = 0.
IF IT_VEKP1_TMP <> IT_VEKP1.
UPDATE VEKP SET ZZPROMDT = IT_VEKP1-ZZPROMDT
ZZOCHOLDRC = IT_VEKP1-ZZOCHOLDRC
WHERE EXIDV = IT_VEKP1-EXIDV.
IF SY-SUBRC = 0.
COMMIT WORK.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM GET_VEKP_DATA .
CLEAR IT_VEKP1_TMP.
REFRESH IT_VEKP1_TMP.
IT_VEKP1_TMP[] = IT_VEKP1[].
PERFORM POPULATE_FINAL_TABLE.
PERFORM DISABLE_EDIT_FIELDS.
PERFORM FORM_REFRESH.
MESSAGE S002 WITH 'Data Saved'(011).
ENDIF.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDFORM. " event_ucomm1
check this code , in that i have used and implemented..using classes -
Hi,
I am having a little problem that is driving me mad . When trying to fill my data-grid noting happens . No error or noting . The only thing i can see is when i run the application a red x is put on my database in the server explorer and when i refresh it
it will return to normal.
Any help would be appreciated.
Thanks.
private void btnSearch_Click(object sender, EventArgs e)
searchAll();
public void searchAll()
OleDbConnection conToDataBase = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Resources\health_plus.accdb;Persist Security Info=True");
OleDbCommand searchAllCom = new OleDbCommand("SELECT * FROM Doctors", conToDataBase);
conToDataBase.Open();
searchAllCom.CommandType = CommandType.Text;
OleDbDataAdapter searchDocAdapter = new OleDbDataAdapter(searchAllCom);
DataTable doctorsTable = new DataTable();
searchDocAdapter.Fill(doctorsTable);
searchDoctorDataGrid.DataSource = doctorsTable;Hi Ali-k,
First you need to make sure the data is in your Access DataBase.
Then If you have binded the DataSource before searchAll method, you could clear the DataSource before resetting it like below.
searchDocAdapter.Fill(doctorsTable);
searchDoctorDataGrid.DataSource = null;
searchDoctorDataGrid.DataSource = doctorsTable;
If you have any other concern regarding this issue, please feel free to let me know.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
MY PROBLEM I am having a DNS problem with my laptop. It connects normally to th e wifi internet but when i try to surf the net it says "DNS Look up failed" This problem only occurs when with the internet at my house. whenever i connect elsewhere my c
-
Ipod classic won't sync to itunes on PC but no problem at all with MAC
Hi, i have this problem for almost a year now. i have tried restoring my ipod (using both itunes & ipod restore option) i have uninstalled and reinstalled itunes, checked it with different computers and different operating systems (XP and windows 7)
-
SQL developer drop all my network connections
Hi all, I have used different versions of SQL Developer and I have read many forum posts but I cannot find solution for my network problem. I can connect to my databases without any problem, but when my session goes to snipped state (due to idle_time
-
Ultiboard 12 - bug exporting gerber X
Hi, I believe there is a bug in Ultiboard 12, gerber X handling. If you export a layer in gerber X format, the files are generated and correctly interpreted by ultiboard 12. The bug becomes apparent when one opens the created gerber files on third pa
-
Booted up new MBPro for the first time and machine hung while trying to find the Time Machine disk from which I was migrating a prior system. That was a sign of bad things to come. Migrated files and rebooted with no problems. Used Software Update to