Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

More Payroll Woes - Importing Hours

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    More Payroll Woes - Importing Hours

    I changed PR services (again) and have to figure out how to get the data they need into a file formatted for their import file.

    My current data is one record per employee - like this:

    FILENO|EMPLOYEE|REG_HRS|OT1|OT2
    1924|Aguirre, Redmedios |40
    1854|Becerril, Candido |40| 20| 9

    plus a few more fields I use for other purposes, but these are the fields I was importing.

    Now I have to do this:

    TYPE_PAY|TYPE_HRS|FILENO|EMPLOYEE|HOURS
    E |REG|1924|Aguirre, Remedios|40
    E |REG|1854|Becerril, Candido|40
    E |OT1|1854|Becerril, Candido|20
    E |OT2|1854|Becerril, Candido|9

    I realize I can just make a new table for my input, but I still need the other one, and my input form does just what I need for the other processing steps. How would I go about using my current table to create this new one?

    I'm thinking a button script could create an XLS file and then I could just skip the extra table.
    Last edited by MoGrace; 04-27-2015, 09:50 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    #2
    Re: More Payroll Woes - Importing Hours

    Robin,

    Attach a sample of your table so we don't have to create one. Tell us what the file type is of the file "they need". There must be some date fields and ranges involved. What time period do you send them? Will all records in the output file begin with E| ?

    these are the fields I was importing
    Exporting?
    There can be only one.

    Comment


      #3
      Re: More Payroll Woes - Importing Hours

      Exporting from A5 to Excel for importing to their SQL database, is my guess. I will get a sample together - stay tuned!
      Robin

      Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

      Comment


        #4
        Re: More Payroll Woes - Importing Hours

        you don't need to export to excel then import to sql, if you prefer.
        if your employee table is
        id numeric
        name character
        employee_id numeric
        regular numeric
        ot1 numeric
        ot2 numeric

        and the destination sql table in my case MySQL and the table is
        id integer
        name varchar
        emp_id integer
        pay_type varchar ( can be reg, ot1, ot2)
        hours numeric
        then you can just create the sql table yourself using xbasic and send it.

        here is a code snippet for you to study

        Code:
        'debug(1)
        dim tbl as p
        dim name as c
        dim eid as n
        dim pay_type as c
        dim regular as n
        dim overtime1 as n
        dim overtime2 as n
        dim cn as sql::Connection
        dim result as l = .f.
        dim sqlInsert as c
        dim args as sql::Arguments
        
        result = cn.Open("::Name::alphasoftware")
        if result then
        		tbl = table.open("mograce")
        		tbl.fetch_first()
        		while .not. tbl.fetch_eof()
        		eid = tbl.e_id
        		name = tbl.name
        		regular = tbl.reg
        		overtime1 = tbl.ot1
        		overtime2 = tbl.ot2
        		sqlInsert = "INSERT INTO mograce (name, emp_id, pay_type, hours ) VALUES (:newName, :newEID, :newPay_type, :newHours)"
        		args.set("newName", name)
        		args.Set("newEID", eid)
        		args.Set("newPay_type", "REG")
        		args.Set("newHours",regular)
        		result = cn.Execute(sqlInsert,args)
        		if result then
        			if overtime1 <> 0 then
        				sqlInsert = "INSERT INTO mograce (name, emp_id, pay_type, hours ) VALUES (:newName, :newEID, :newPay_type, :newHours)"
        				args.Set("newPay_type", "OT1")
        				args.set("newHours",overtime1)
        				result = cn.Execute(sqlInsert,args)
        				if result then
        					if overtime2 <> 0 then
        						sqlInsert = "INSERT INTO mograce (name, emp_id, pay_type, hours ) VALUES (:newName, :newEID, :newPay_type, :newHours)"
        						args.Set("newPay_type", "OT2")
        						args.Set("newHours",overtime2)
        						result = cn.Execute(sqlInsert,args)
        					end if
        				end if
        			end if
        		end if
        	tbl.fetch_next()
        	end while
                tbl.close()
        	cn.close()
        else
        	msgbox("ERROR", "Unable to connectt to database")
        end if
        start dbf table:
        dbf file
        http://screencast.com/t/NGletOtfc
        end sql table:
        http://screencast.com/t/wYytzWWXi

        obviously you will need to adjust to all the fields in your table and name them accordingly and name the connection string as you have defined.

        edit: you see double entry for aguire since I ran twice to test using debug. also you can set to add E as the first field.
        Last edited by GGandhi; 04-28-2015, 06:51 AM.
        thanks for reading

        gandhi

        version 11 3381 - 4096
        mysql backend
        http://www.alphawebprogramming.blogspot.com
        [email protected]
        Skype:[email protected]
        1 914 924 5171

        Comment


          #5
          Re: More Payroll Woes - Importing Hours

          Gandhi,

          I imagine she's sending the Excel file to the payroll processing company and they import on their end.

          Probably be better to have a plain text file. They can open that in excel if they want. Script below writes all records to the text file. No allowance for choosing date rante. That would have to be added to the three queries.

          Code:
          tbl = table.open("empdata") 'adjust table name
          ix = tbl.query_create("T","isnotblank(\"reg_hrs\")","fileno")
          tbl.fetch_first()
          fil = file.create("c:\temp\paydata.txt",FILE_RW_EXCLUSIVE) 'adjust output location and name as desired
          fil.write_line("TYPE_PAY|TYPE_hRS|FILENO|EMPLOYEE|HOURS")
          while .not. tbl.fetch_eof()
          	file.write_line("E|REG|"+alltrim(tbl.fileno)+"|"+alltrim(tbl.employee)+"|"+alltrim(str(tbl.reg_hrs,10,2)))
          	tbl.fetch_next()
          end while
          ix.drop()
          jx = tbl.query_create("T","isnotblank(\"ot1\")","fileno")
          tbl.fetch_first()
          while .not. tbl.fetch_eof()
          	file.write_line("E|OT1|"+alltrim(tbl.fileno)+"|"+alltrim(tbl.employee)+"|"+alltrim(str(tbl.OT1,10,2)))
          	tbl.fetch_next()
          end while
          Jx.drop()
          Kx = tbl.query_create("T","isnotblank(\"ot2\")","fileno")
          tbl.fetch_first()
          while .not. tbl.fetch_eof()
          	file.write_line("E|OT2|"+alltrim(tbl.fileno)+"|"+alltrim(tbl.employee)+"|"+alltrim(str(tbl.OT2,10,2)))
          	tbl.fetch_next()
          end while
          kx.drop()
          fil.flush()
          fil.close()
          tbl.close()
          Last edited by Stan Mathews; 04-28-2015, 09:00 AM.
          There can be only one.

          Comment


            #6
            Re: More Payroll Woes - Importing Hours

            oh, I see. you are right.
            thanks.
            thanks for reading

            gandhi

            version 11 3381 - 4096
            mysql backend
            http://www.alphawebprogramming.blogspot.com
            [email protected]
            Skype:[email protected]
            1 914 924 5171

            Comment


              #7
              Re: More Payroll Woes - Importing Hours

              Hi Gandhi,
              This is an online payroll service so I cannot write to their table directly, but can upload my data with a properly formatted file.

              Stan,
              You didn't wait for my table! But that's ok because you gave me what I needed to get started with this - thanks!
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment


                #8
                Re: More Payroll Woes - Importing Hours

                okay I understand after stan pointed out to me. if you desire to create an excel file then
                the code may be changed to. hopefully this works.
                Code:
                'debug(1)
                dim tbl as p
                dim employee_id as n
                dim name as c
                dim regular as n
                dim overtime1 as n
                dim overtime2 as n
                
                dim Doc as Office::Excel2003Document
                dim Sheet as Office::Spreadsheet
                dim row as n = 1
                dim col as n = 1
                
                Sheet = doc.AddSheet("employee data")
                sheet.Write(row,col,"EMP ID")
                sheet.Write(row,col+1,"EMP Name")
                sheet.Write(row,col+2,"Pay Type")
                sheet.Write(row,col+3,"Hours")
                
                tbl = table.open("mograce")
                tbl.fetch_first()
                while .not. tbl.fetch_eof()
                	employee_id = tbl.emp_id
                	name = tbl.name
                	regular = tbl.reg
                	overtime1 = tbl.ot1
                	overtime2 = tbl.ot2
                	row = row+1
                	sheet.Write(row,col,employee_id)
                	sheet.Write(row,col+1,name)
                	sheet.Write(row,col+2,"REG")
                	sheet.Write(row,col+3,regular)
                	if overtime1 != 0 then
                		row = row+1
                		sheet.Write(row,col,employee_id)
                		sheet.Write(row,col+1,name)
                		sheet.Write(row,col+2,"OT1")
                		sheet.Write(row,col+3,overtime1)
                		if overtime2 != 0 then
                			row = row+1
                			sheet.Write(row,col,employee_id)
                			sheet.Write(row,col+1,name)
                			sheet.Write(row,col+2,"OT2")
                			sheet.Write(row,col+3,overtime2)
                		end if
                	end if
                	tbl.fetch_next()
                	end while
                	tbl.close()
                	doc.Save("c:\temp\employee_data.xls")
                	msgbox("Table exported to excel")
                delete doc
                dbf:
                http://screencast.com/t/eyN21ajdU

                excel end:
                http://screencast.com/t/myVrY3Kzg
                thanks for reading

                gandhi

                version 11 3381 - 4096
                mysql backend
                http://www.alphawebprogramming.blogspot.com
                [email protected]
                Skype:[email protected]
                1 914 924 5171

                Comment

                Working...
                X