Report of sales orders and detail (Report Writer)

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Report of sales orders and detail (Report Writer)

Post by jparada »

Hi,

Anyone can please share with me some code about how to make a report (report writer), I have seen the examples (report.advanced.x), but I did not understand how to implement my own report of sales orders and detail (this is very common to us all):

My idea is to do something like the image attached, please take a look.

I appreciate any help.

Thanks

Best Regards
Javier
Attachments
img01.png
img01.png (26.13 KiB) Viewed 4702 times
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Report of sales orders and detail (Report Writer)

Post by jparada »

Hi,

I just need a little "push" to understand, please, please, please.

Thanks

Best Regards
Javier
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Report of sales orders and detail (Report Writer)

Post by Rathinagiri »

IMHO, You can use GridPrint also. I would come with a small example.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Alex Gustow
Posts: 290
Joined: Thu Dec 04, 2008 1:05 pm
Location: Yekaterinburg, Russia
Contact:

Re: Report of sales orders and detail (Report Writer)

Post by Alex Gustow »

Hi Javier!
In what kind of information you want to get such reports? (i.e. "for look and print only" - using print with preview, or "for look, manipulation, print, save as" - using export to Excel/Word/OpenOffice etc.)
I have some expiriense (not great :) ) to create something like you want in your post - using export to Excel (with data formatting like I need, borders etc. - programmatically of course). If you need - I'll can post more about it.
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Report of sales orders and detail (Report Writer)

Post by jparada »

Hi Alex,

Thanks for answering.

My first response should be, I just need to preview and print the information, but ... to be honest, export the information to at least Excel is the next step should I follow. So if you can please help me with something about preview, print and export that would be great.

Thanks Alex, just for answer.

Best Regards
Javier
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Report of sales orders and detail (Report Writer)

Post by jparada »

Hi Rathinagiri,

Thanks for answering.

I've never taken a look at GridPrint, maybe I should try.

Thanks.

Best Regards
Javier
User avatar
Alex Gustow
Posts: 290
Joined: Thu Dec 04, 2008 1:05 pm
Location: Yekaterinburg, Russia
Contact:

Re: Report of sales orders and detail (Report Writer)

Post by Alex Gustow »

Hi Javier!

At first - did you see at "Samples\Advanced\REPORT_INTERPRETER" (I say about samples in "HMG Ext." - I don't know is this exists in samples of original HMG)? This is good example of such kind of tasks.

If you need - I'll write simple sample for you (how I do such things).

But another question: which way is more likely for you?

1) all work is written into application code (i.e. which field values from which database must be exported to which column in XLS; formatting, borders etc) - in other words: you write all commands to app code only (and if you want to change something in report view, you must change app code and recompilied it) ("pro": user can't change - and can't "spoil" - anything into report view; "contra" - if he [or you] need a little changing, you must change and recompile application, not a "template" file).

2) you write a lot of "template" files (simple text files - like .RPT or other; you can see like example .MOD files in REPORT_INTERPRETER) and into you app you write only code for to choice which "template" you need to use in this case and code for "interpretation" of commands from "template" ("pro": you don't need to recompile your app any time for any little changing; "contra" - anyone can [even without malice, by mistake] change anything in any "template" file; this will entail changing of report view, and even an app crash... and in some cases, you'll have to spend a lot of time to understand why the program works not as intended by you).

So - which way you preferred?
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Report of sales orders and detail (Report Writer)

Post by jparada »

Hi Alex,

Thanks for answering.
At first - did you see at "Samples\Advanced\REPORT_INTERPRETER" (I say about samples in "HMG Ext." - I don't know is this exists in samples of original HMG)? This is good example of such kind of tasks.
I do not use the extended version of HMG, so I have not seen such examples.
But another question: which way is more likely for you?
All my work on reports is embedded within the application.

Thanks Alex.

Best Regards
Javier
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Report of sales orders and detail (Report Writer)

Post by Rathinagiri »

Hi,

Please consider this small sample.

Code: Select all

#include <hmg.ch>
#include "hfcl.ch"

Function Main
define window main at 0,0 width 800 height 600 main
   define grid details
      row 10
      col 10
      width 780
      height 500
      headers {"Invoice Number","Date & DueDate","Transaction Type","Ship Via","Sales Rep    Attention","Paid","Invoice Total"}
      widths {80,120,100,100,200,60,100}      
      justify {0,0,1,0,0,1,1}
   end grid
   define button print
      row 520
      col 10
      width 80
      caption "Print"
      action printreport()
   end button    
end window
main.details.additem({"SI-10027","01/05/2008 31/05/2008","Invoice","UPS Ground","SR10006   124115","No","8320.85"})
main.details.additem({"","","","","","",""})
main.details.additem({"","Item Number","Shipped","","Description","Sales Price","Total"})
main.details.additem({"","SHIRT-2-S","5","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","425.00"})
main.details.additem({"","SHIRT-3-S","4","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","340.00"})
main.details.additem({"","SHIRT-1-M","20","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","1700.00"})
main.details.additem({"","SHIRT-2-M","0","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","0.00"})
main.details.additem({"","SHIRT-3-M","0","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","0.00"})
main.details.additem({"","SHIRT-1-L","18","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","1530.00"})
main.details.additem({"","SHIRT-2-L","18","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","1530.00"})
main.details.additem({"","SHIRT-3-L","1","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","85.00"})
main.details.additem({"","SHIRT-1-X","0","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","0.00"})
main.details.additem({"","SHIRT-2-X","8","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","680.00"})
main.details.additem({"","SHIRT-3-X","0","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","0.00"})
main.details.additem({"","SHIRT-1-S","15","","Tommy Bahama Relax 'Aruba' Zip Sweat Shirt","85.00","1275.00"})
main.details.additem({"","","","","","Freight","75.00"})
main.details.additem({"","","","","","Tax","680.85"})
main.details.additem({"","","","","","Total","4700.00"})
main.center
main.activate
Return

function printreport
PRINT GRID details ;
   OF main ;
	 FONT "Arial"    ;
	 SIZE 8    ;
	 ORIENTATION "P"  ;
   WIDTHS {25,31,15,15,39,10,20};
   PAPERSIZE PRINTER_PAPER_A4

return nil
Don't forget to include the path 'c:\hmg\hfcl\include' in additional include paths and 'hfcl' in additional library.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply