cancel
Showing results for 
Search instead for 
Did you mean: 

Header / Line Item in Printing Forms

justin_santhanam
Active Contributor
0 Kudos

Dear all,

I'm struggling with an issue in taking the values from the line item and putting into the header of the form. Can you please help me out with the scripting?

I hope the requirement is clear, please let  me know if it isn't..

Form Header:

Form Detail (also Content Area):

This is the ITAB coming into the form.

Based on the combination of WERKS and LGORT(Storage Location),  I need to create a  new page. I have achieved this using Conditional break and it's working fine. If there are more line items and it exceeds the content area, it flows to the next page, no issues here as well.

So the output will look like below for the example given above.

So the question here is, I need to take the first LGORT on the given page and display it on header (each page will have header and Detail). So the first page will have no storgage location (LGORT) in header, the second page will have 0720 as storage location (LGORT) in header and the third page will have 0900 as storage location (LGORT) in header.

Basically what I want is in the content area the first DATA elements LGORT on each page. How can I get this?

I apologize if I wasn't clear on the requirement. Sincerely appreciate your time and effort!

Thank you,

Justin.

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Hello Piyush,

I just wanted to update you and get opinion. I finally got it working through Coding in the Interface (Code Initialization). The below coding will work in conjunction with the content area (assuming that no one else will increase the content area). I have run it and in a given page I can have maximum of 9 line items (DATA[*]) in a given page, rest data will flow to the next page. I have taken the same coding in Conditional Editor and with the content area limit , I'm generating the GT_LGORT_HDR table. The ITAB will have exact no.of LGORT for each page.


LOOP AT GT_VBLKP INTO GS_VBLKP.

  LV_COUNTER = LV_COUNTER + 1.

  IF SY-TABIX = 1.

    LS_LGORT-LGORT = GS_VBLKP-LGORT.

    APPEND LS_LGORT TO LT_LGORT.

  ELSE.

    IF LV_COUNTER = 9 OR LV_LGORT <> GS_VBLKP-LGORT OR LV_WERKS <> GS_VBLKP-WERKS.

      LS_LGORT-LGORT = GS_VBLKP-LGORT.

      APPEND LS_LGORT TO LT_LGORT.

      LV_COUNTER = 0.

    ENDIF.

  ENDIF.

  LV_LGORT = GS_VBLKP-LGORT.

  LV_WERKS = GS_VBLKP-WERKS.

ENDLOOP.

MOVE-CORRESPONDING LT_LGORT to GT_LGORT_HDR.

Then in the Scripting for GV_LGORT , I'm taking the Page number and passing it to the GT_LGORT_HDR table to get the LGORT.

It's working fine. But need your inputs, is this okay?

Thank you,

Justin.

Piyushmatrixs
Participant
0 Kudos

Hello Justin,

   Yes, If it works correctly then You should go with this. Use such a test data that your internal table have at least 3 different type LGORT.

Now, about screenshot provided by you.

1.  In below screenshot

It looks from binding, you are using a data type for LGORT to pass value from interface not a internal table.

    If you use LGORT as data type, syntax would be different. If you use Internal table to display LGORT then syntax would be different.

2. You use my code with same text as I gave you. Based on binding you should modified it.

3. Based on your binding ($.LGORT) in screenshot for LGORT field. After selecting field

    "GV_LGORT" you should use script like below:

  

   var v_lgort = xfa.resolveNode("xfa.record.LGORT").value;

   this.rawValue = v_lgort;

4. OR if you are not passing LGORT as data type, you are passing and using it like a field of internal

    table, then at based on context area screenshot in interface, it should be like below: (if LGORT is

    field of internal table VBLKP)

  

    var v_lgort = xfa.resolveNode("xfa.record.VBLKP.DATA[*].LGORT").value;

   this.rawValue = v_lgort;

5. Based on your binding for LGORT, I will recommend you to use script in point 3. It will reduce extra coding in interface, and help you to not restrict the content area for 9 records only.

6. If use my code, please don't use Below code, comment it.

You must modified my script according binding.

Regards

Piyush

justin_santhanam
Active Contributor
0 Kudos

Hello Piyush,

I'm sorry , the script (step 3) still not bringing in any value. Just for my clarity, can you explain what you are trying to do in the below script? Please apologize my ignorance.

  var v_lgort = xfa.resolveNode("xfa.record.LGORT").value;


Thank you,

Justin.     

Piyushmatrixs
Participant
0 Kudos

Hello Justin,

   After watching your screenshot of binding for LGORT field on body page, it seems that you are passing individual value of LGORT from interface, you are not passing internal table having field LGORT.

By your binding it denotes

   xfa.resolveNode("xfa.record.lgort").value   =  value of lgort field on body page

I am assigning value of LGORT field in a variable named "v_lgort" .

Then I am displaying value of variable "v_lgort" on selected field at master page like below:

this.rawValue = v_lgort;

Regards

Piyush

justin_santhanam
Active Contributor
0 Kudos

Piyush,

LGORT field is under DATA. DATA is repeatable element (Internal table).

Justin.

Piyushmatrixs
Participant
0 Kudos

Hello Justin,

   what you are saying is correct, but only after you made changes in interface and created table "GT_LGORT_HDR".

    Before this table binding for LGORT field was $.LGORT, but after creating table "GT_LGORT_HDR" binding for LGORT field would be changed something like

$.GT_LGORT_HDR.DATA[*].lgort.


Am I correct?


Regards

Piyush

justin_santhanam
Active Contributor
0 Kudos

Hello Piyush,

I think we are confusing with two different solutions here. GT_LGORT_HDR was created in Interface code Initialization. But the solution you are providing is an alternative to that isn't it? Can you send me an email to Justin.Santhanam@gmail.com (if you are okay with it, if not we can discuss here itself)? I'll send the Form and Layout.

@Moderators - Please apolgoize for using the email communication here. I need to attach some files, so using the personal communication here. But definitely will update the thread with solution.

Thank you,

Justin.

Piyushmatrixs
Participant
0 Kudos
Hello Justin,

    Yes, Now you got me.  When I told you the script based on screenshot of binding, you did not create GT_LGORT_HDR table in interface. After that you told me that you have created this table and program is working according your requirement.
  I suggested you an simple alternative of creating table in interface, and had told you clearly
     

It's up to you that you want solve it by doing extra efforts in interface or want to solve it by using simple script on form layout.

Regards

Piyush

Answers (3)

Answers (3)

justin_santhanam
Active Contributor
0 Kudos

Had to redesign the layout.. Somehow I can't able to get it work with the standard delivered content.

justin_santhanam
Active Contributor
0 Kudos

Hello Piyush,

I'm sorry I think there was a confusion. The script I have given that was not for conditional breaks, if you see I have said it is for GV_LGORT  - event Calculate. The script is taking the values from LGORT and  putting it into GV_LGORT.  I have disabled that calculate scripting and executed your script all these time. I just pointed that script to you, to tell that's what SAP had it by default for GV_LGORT.

Now to answer your questions.

1)Please see the below screenshot

2) GV_LGORT field is defined at the Interface, but it's not binded.

3) This is responsible for Conditional Break, not the script which I have given earlier.


( DATA[-1].WERKS ne DATA.WERKS ) or ( DATA[-1].LGORT ne DATA.LGORT ) or ( DATA[-1].LGNUM ne DATA.LGNUM )

Thank you,

Justin.

justin_santhanam
Active Contributor
0 Kudos

Any one have an answer for the question. Please let me know if it wasn't clear.

Piyushmatrixs
Participant
0 Kudos

Hi Justin,

  In your earliest related post, it was not so clear. But here your requirement is clear.

    Before answering you, I would like to ask a few questions:

1. Are you using a standard driver program or you have developed a Z driver program?

2. you said that "

  "

How did you achieve this? Where did you use conditional break in Driver program/ In Interface / or in Form?

Please provide answers of above questions. I will solve your problem asap.

Regards

Piyush

justin_santhanam
Active Contributor
0 Kudos

Hi Piyush,

I'm using the conditional break in the forms on DATA Level. This is the copy of stand SD_PICK_SINGLE Form, so I'm using the same interface (copied to Z*) and same form (Copied to Z*) to make some custom cosmetic changes and removing some additional fields so on. But one thing I have noticed as well, the DATA table is not in the layout it is hidden from Layout. SAP is just using this as a place holder I guess to populate the header level.

Being all said, I have modified the Interface and created Z table as well which will have exactly LGORT in it for each page. If there are 11 pages there will be 11 LGORT's , if there are 12 pages then there will 12 LGORT's etc.. I have made some logic to achieve this. If the above requirement is little bit tricky, can I ask how can I put the new table LGORT I created and put it in the header of each page? I think this will be little bit less work comparing to the earlier one I guess.

Let me know!

Justin.     

Piyushmatrixs
Participant
0 Kudos

Hello Justin,

   It would be much easier If you use a Z driver program. But know issue, you can also achieve your requirement by using java script. Do as below:

1.  Suppose you internal table "Item_table" (On body page) has below fields:

      ITEM_TABLE

          VBELN

          POSNR

          MATNR

          WERKS

          LGORT

2. GV_ALGORT is a text field on master page.

3. in script, path for ITEM_TABLE-LGORT would be like below:

      xfa.record.IT_TABLE.DATA[*].LGORT

4. Now, Select GV_LGORT text field on master page.

5. Go and select "Ready:Layout" event, "JavaSceipt" as language and "Client" as Run At.

6. Write below code (you can change path like mentioned in point 3 if item_table is nested in other

    structure or internal table  😞

 

   var v_lgort = xfa.resolveNode("xfa.record.IT_TABLE.DATA[*].LGORT").value;

   this.rawValue = v_lgort;

Note: If above is not working.then select above code and delete, press save button. And write same code under "Form:ready" event.

   I hope it will solve your problem. Reward point if it solve your problem.

Regards

Piyush

justin_santhanam
Active Contributor
0 Kudos

Hello Piyush,

Sorry for the late reply, I tried all the options in layout:ready as well as form:ready, but no luck.. The value wasn't showing up at all. I tried both the below options.

//var v_lgort = xfa.resolveNode("data.Body.Item_Table.DATA[*].LGORT").value;

var v_lgort = xfa.resolveNode("xfa.record.Item_Table.DATA[*].LGORT").value;

this.rawValue = v_lgort;

This is the logic they(SAP) have written in GV_LGORT . But I don't understand this logic at all. I mean I understand the coding , but I don't understand how this logic will ever work.. The below code brings in Storage Location (LGORT), but not in the expected way..

Let me know if any other way we can sort this out. I sincerely appreciate your help.

Thanks,

Justin

Piyushmatrixs
Participant
0 Kudos

Hello Justin,

1.  Please provide screenshot for binding of LGORT field.

2.  what is the type GV_LGORT field?  Have you declared it in interface or simply took a text field on

     master page and named it as GV_LGORT?

3. You had told that you applied conditional break then what is the need of below script

4. Run the program without above code, but use my provided code. And see if you conditional break is working or not without above formCalc script.

  

Let me know the above four points

Regards

Piyush